Back

How to Immediate login user after password is reset .

  • 0
  • Self Hosted
  • Flutter
  • Auth
Shiba
19 Aug, 2024, 05:20
TypeScript
 Future<bool> resetPassword(
    ParamsForPassword resetPassword,
    String newPassword,
  ) async {
    try {
      await account.updateRecovery(
        userId: resetPassword.userId,
        secret: resetPassword.secret,
        password: newPassword,
      );
      return true;
    } on AppwriteException catch (e) {
      Utils.toast(e.message ?? "");
      Utils.debLog(e);
      return false;
    }
  }
TypeScript
      account.createSession(userId: userId, secret: secret)
TypeScript
      final user = await account.get();
  1. updateRecovery() gives me Token in return ;
  2. took the Token.secret account.createSession(userId: resetPassword.userId, secret: Token.secret)

giving error as Token invalid !!

TL;DR
When resetting a password, developers can create a new session for the user using the token from `updateRecovery()`. To fix the "Token invalid" error, make sure to correctly pass the user ID and corresponding token when creating the session.
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