Skip to main content
Version: 0.24

Interface: UsernameAndPasswordConfig

Username and password auth configuration.

Exampleโ€‹

import { app } from "@wasp.sh/spec"
import { userSignupFields } from "./src/auth" with { type: "ref" }

export default app({
// ...
auth: {
userEntity: "User",
methods: {
usernameAndPassword: {
userSignupFields,
},
},
onAuthFailedRedirectTo: "/login",
},
})

Extendsโ€‹

  • BaseAuthMethodConfig

Propertiesโ€‹

userSignupFields?โ€‹

optional userSignupFields?: Reference<AnyObject>

Object that defines extra fields to save on the user during signup (e.g. firstName, address). Each field name must exist on the configured Auth.userEntity.

Each field function receives the data sent from the client and returns the value Wasp saves to the database. For social auth, this data includes provider-specific profile information. If the value is invalid, throw an error. The password field is excluded from this object and handled by Wasp's auth backend.

See Signup Fields Customization.

Exampleโ€‹

import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
address: (data) => {
if (!data.address) {
throw new Error('Address is required')
}
return data.address
},
phone: (data) => data.phone,
})

Inherited fromโ€‹

BaseAuthMethodConfig.userSignupFields