Esta versão (v0.7) ainda não foi publicada no npm.
Pular para o conteúdo

Senha ​

Carregando a demo interativa…

A demo acima roda o SDK de verdade (createEnginexClient) com fetch: createMockFetch(...) de @getenginex/sdk/testing: nenhuma chamada sai para a rede. Na aba Change while signed in, a primeira tentativa dá PASSWORD_SAME_AS_CURRENT de propósito. O painel Under the hood mostra a chamada feita (senhas e tokens mascarados), os requests vistos pelos hooks, o resultado ou o EnginexError e a sessão. O código abaixo é o equivalente para o seu app.

Esqueci a senha ​

ts
await enginex.auth.forgotPassword({ email })             // always resolves
await enginex.auth.resetPassword({ email, token, newPassword })  // token from the email

Trocar a senha logado ​

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
}

Trocar o telefone ​

ts
await enginex.auth.requestPhoneChange({ newPhone })  // sends an OTP to the new number
await enginex.auth.confirmPhoneChange({ otp })