Documentation for `login` action

Is the documentation for the login action perhaps incorrect? The API reference at /auth/username-and-pass#1-using-the-signup-and-login-actions shows that the function takes username: string and password: string, but the member exported from wasp/client/auth shows that it takes data: { email: string; password: string } Wasp version: 0.13.2
Username & Password | Wasp
Wasp supports username & password authentication out of the box with login and signup flows. It provides you with the server-side implementation and the UI components for the client side.
No description
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @JakeLoew. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The login action in Wasp can be used with both username and password or email and password, depending on the authentication method you are using. If you are using the Username & Password (https://wasp-lang.dev/docs/auth/username-and-pass#login) authentication method, the login action takes two arguments: username: string and password: string. Here is an example of how you can use it:
import { login } from 'wasp/client/auth'

export function LoginPage() {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')

async function handleSubmit(event) {
event.preventDefault()
try {
await login(username, password)
history.push('/')
} catch (error) {
setError(error)
}
}

return (
<form onSubmit={handleSubmit}>
{/* ... */}
</form>
);
}
import { login } from 'wasp/client/auth'

export function LoginPage() {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')

async function handleSubmit(event) {
event.preventDefault()
try {
await login(username, password)
history.push('/')
} catch (error) {
setError(error)
}
}

return (
<form onSubmit={handleSubmit}>
{/* ... */}
</form>
);
}
On the other hand, if you are using the Email authentication method, the login action would take data: { email: string; password: string }. This is suggested in a Github issue (https://github.com/wasp-lang/wasp/issues/1698) where it is proposed to merge the login and signup actions for both username and email auth methods into one template file. However, this change has not been implemented yet. Please note that the actual implementation might differ based on the version of Wasp you are using and the specific authentication method you have chosen. Always refer to the official Wasp documentation for the most accurate and up-to-date information. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @JakeLoew, 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?
JakeLoew
JakeLoew2mo ago
I see. Thank you.
Want results from more Discord servers?
Add your server