Password
Loading the interactive demo…
The demo above runs the real SDK (createEnginexClient) with fetch: createMockFetch(...) from @getenginex/sdk/testing: no call goes out to the network. In the Change while signed in tab, the first attempt fails with PASSWORD_SAME_AS_CURRENT on purpose. The Under the hood panel shows the call made (passwords and tokens masked), the requests seen by the hooks, the result or the EnginexError, and the session. The code below is the equivalent for your app.
Forgot password
ts
await enginex.auth.forgotPassword({ email }) // always resolves
await enginex.auth.resetPassword({ email, token, newPassword }) // token from the emailChange the password while logged in
ts
try {
await enginex.auth.changePassword({ currentPassword, newPassword })
} catch (e) {
if (isEnginexError(e, 'INVALID_CREDENTIALS')) showError('Current password is incorrect')
else if (isEnginexError(e, 'PASSWORD_SAME_AS_CURRENT')) showError('Choose a different password')
else throw e
}Change the phone number
ts
await enginex.auth.requestPhoneChange({ newPhone }) // sends an OTP to the new number
await enginex.auth.confirmPhoneChange({ otp })