import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.auth.resetPassword(
"user",
"emailpass",
{
identifier: "user@gmail.com"
}
)
.then(() => {
// user receives token
})Generate a reset password token for an admin user. This API route doesn’t reset the admin’s password or send them the reset instructions in a notification.
Instead, This API route emits the auth.password_reset event, passing it the token as a payload. You can listen to that event in a subscriber as explained in this guide, then send the user a notification. The notification is sent using a Notification Module Provider, and it should have the URL to reset the password in the Medusa Admin dashboard, such as http://localhost:9000/app/reset-password?token=123.
Use the generated token to update the user’s password using the Reset Password API route.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.auth.resetPassword(
"user",
"emailpass",
{
identifier: "user@gmail.com"
}
)
.then(() => {
// user receives token
})The provider used for authentication.
"emailpass"
The user's identifier for the selected auth provider. For example, for the emailpass auth provider, the value is the user's email.
OK