Back

[SOLVED]Updating recovery returns exception while still updating the user's password in the backend

  • 0
  • Flutter
zjjt
4 Aug, 2023, 10:36

Oh i see , i might have confused you on the flow of things. first the PasswordResetRoute which is the top level component gets the query parameters from the url and pass those along to the PasswordResetPage which is another component whose main job is to apply responsive /adaptive design based on the current platform and layout. this widget passes then the userId and the secret to PasswordResetScreen which contains the form for the user to input his new password and confirmation of the new password. On submit those 4 are passed to the controller which then passes them to the usecase which calls the repository with those 4. this is the code you've read above.

TL;DR
The user is experiencing an exception while updating the password recovery process. They are trying to log in the user immediately after updating the recovery, but they are unable to retrieve the user's email in their code, so they are redirecting the user to the login screen instead. The user is unsure if they should call `account.get()` after updating the recovery. They are also encountering an error when calling `account.get()`, which is expected because the user doesn't have a session. A solution provided is to log in the user with `account.createEmailSession()` and then call `account.get()`. Additionally, the user is advised
zjjt
4 Aug, 2023, 10:37

@D5 yes i made a print of those 4 at each level and they are correctly extracted

D5
4 Aug, 2023, 11:59

First you need to trigger account.passwordreset

D5
4 Aug, 2023, 12:00

And then updaterecovery

zjjt
4 Aug, 2023, 12:03

@D5 yes indeed and i do that on my PasswordForgottenRoute . it follows the same process i explained above and triggers this @override FutureEither<Token> passwordForgotten({ required String email, required String url, }) async { try { final token = await _accountService.createRecovery( email: email, url: url, ); return Right(token); } on AppwriteException catch (e, stackTrace) { print(e); return Left(Failure(e.message ?? "error", e, stackTrace)); } catch (e, stackTrace) { return Left(Failure("error", e, stackTrace)); } } and when i receive the email and i click on it i get redirected to my app at my PasswordResetRoute and the rest is as you already know.

Drake
4 Aug, 2023, 16:11

do you know what endpoint throws this error?

zjjt
4 Aug, 2023, 16:13

@Steven, yeah it is this one final token = await _accountService.updateRecovery( userId: userId, secret: secret, password: password, passwordAgain: confirmPassword, ); since the app is opened in chrome and the error seems pretty similar to the one we dealt with last time, i tried deleting the cache but it didnt work

zjjt
4 Aug, 2023, 16:13

@Steven it updates the password fine though

Drake
4 Aug, 2023, 16:14

what version of appwrite?

zjjt
4 Aug, 2023, 16:14

@Steven 1.3.8

Drake
4 Aug, 2023, 17:02

i wonder if it's throwing an exception from one of these: https://github.com/appwrite/appwrite/blob/e26062ca87c0fd97e47a910d22c6bbbee887b74f/app/controllers/api/account.php#L2194-L2200...it would be helpful if you could grab some sort of stacktrace. i think if you have the _APP_ENV variable set to developoment, it might show a stack trace

zjjt
4 Aug, 2023, 17:05

@Steven ill see how i can get a stacktrace ...yes my _APP_ENV is set to development

Drake
4 Aug, 2023, 17:10

the api call should return it then 🧐

zjjt
4 Aug, 2023, 17:11

@Steven i thought i had to look in the containers log from appwrite side... Ok let me retry and ill post the stacktrace from my chrome console

zjjt
6 Aug, 2023, 20:04

@Steven i really dont know what causes this issue...here are the screenshots the stacktrace is in the txt file...i modified it with some values for the data i think is sensitive

Drake
6 Aug, 2023, 20:08

You're getting an error calling account.get() which is expected since the user doesn't have a session

Drake
6 Aug, 2023, 20:09

Switch to the network tab instead of the console tab

zjjt
6 Aug, 2023, 20:09

@Steven ok

zjjt
6 Aug, 2023, 20:12

@Steven i now see where i messed up...the recovery itself is fine...i might do something like password reset and log in right away

zjjt
6 Aug, 2023, 20:14

indeed that is it ....

Drake
6 Aug, 2023, 20:34

Or not call account.get() after?

zjjt
6 Aug, 2023, 20:57

@Steven yes I thought it would be good to log in the user just after and not go to the login screen for that ...I removed the call to account.get() but I have no way in my code of getting the user's email so I'll just let him go to the login screen and go from there

zjjt
17 Aug, 2023, 12:31

[SOLVED]Updating recovery returns exception while still updating the user's password in the backend

Drake
17 Aug, 2023, 17:57

you can log the user in with account.createEmailSession() and then call account.get()

zjjt
17 Aug, 2023, 21:23

@Steven thanks I did as you suggested

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