Back

How to determine if a user has set a password for their account?

  • 1
  • Accounts
  • Web
WildAnimal
13 Jul, 2023, 07:56

Since most of my users log in using MagicUrl, I also hope that users can set a password after logging in so that they can log in with it in exceptional circumstances. Now, I want to check if the user has already set their password to determine whether to use the updatePassword or createRecovery and updateRecovery methods to set their password. How to check?

TL;DR
To determine if a user has set a password for their account, you can look at the `passwordUpdate` attribute on the User. If the attribute is null or empty, it means the user has not set a password. In this case, you can use the `createRecovery` and `updateRecovery` methods to set a password. Otherwise, if the attribute is not null or empty, you can use the `updatePassword` method even if the user doesn't have a password yet. Simply pass anything for the password parameter. For more information, refer to the links provided: - Updating password: <https://app
WildAnimal
13 Jul, 2023, 07:58

Supplement: The user has already logged in.

Drake
13 Jul, 2023, 16:26

determine whether to use the updatePassword or createRecovery and updateRecovery methods

You should be able to use updatePassword even if they don't have a password. you can pass anything for the password param.

See https://appwrite.io/docs/client/account?sdk=web-default#accountUpdatePassword

I want to check if the user has already set their password

Try looking at the passwordUpdate attribute on the User.

See https://appwrite.io/docs/models/user

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more