Google auth configFn and userSignupFields
When I add either of these functions to my main.wasp, I get errors.
My google auth method looks like this:
google: { configFn: import { getConfig } from "@src/pages/auth/google.jsx", userSignupFields: import { userSignupFields } from "@src/pages/auth/google.jsx" }, I have a google.jsx file created under src/pages/auth/google.jsx with the following: import { defineUserSignupFields } from 'wasp/server/auth' export const userSignupFields = defineUserSignupFields({ displayName: (data) => data.profile.name, address: (data) => { if (!data.address) { throw new Error('Address is required') } return data.address }, phone: (data) => data.phone, })
export function getConfig() { return { scopes: ['profile', 'email'], } }
google: { configFn: import { getConfig } from "@src/pages/auth/google.jsx", userSignupFields: import { userSignupFields } from "@src/pages/auth/google.jsx" }, I have a google.jsx file created under src/pages/auth/google.jsx with the following: import { defineUserSignupFields } from 'wasp/server/auth' export const userSignupFields = defineUserSignupFields({ displayName: (data) => data.profile.name, address: (data) => { if (!data.address) { throw new Error('Address is required') } return data.address }, phone: (data) => data.phone, })
export function getConfig() { return { scopes: ['profile', 'email'], } }
3 Replies
Hi @cmilazzo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided, it seems like you have correctly implemented the
configFn
and userSignupFields
functions in your google.jsx
file. However, the error might be due to the location of your google.jsx
file.
In the Wasp documentation, the configFn
and userSignupFields
are imported from a file located in the src/auth
directory, not src/pages/auth
.
Here is how it's done in the documentation:
Source: Wasp Documentation (https://wasp-lang.dev/docs/auth/social-auth/google#api-reference)
Try moving your google.jsx
file to the src/auth
directory and update the import statements in your main.wasp
file accordingly:
If you still encounter errors, please provide the specific error messages for further assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @cmilazzo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Let me check the knowledge base for you again. One moment! :books:You defined those fields in .jsx files -> in client code. That is not right, they should instead be define as a server code! You can create @src/auth/google.js file and define them there.
I see now in the docs however that it is not clear these have to be server functions, so I opened this issue: https://github.com/wasp-lang/wasp/issues/2342
GitHub
Google Auth: userSignupFields and getConfig: we don't say they need...
We had a user getting errors here because we was importing these functions from .jsx file: https://discord.com/channels/686873244791210014/1296186131918098536/1296186131918098536 . I looked in the ...