Skip to content

recoverAccount workflow #28

Closed
Closed
@ljosberinn

Description

@ljosberinn

Hi, so I've been tinkering with a reset-password route for a while and found this issue:

  • request a password recovery via requestPasswordRecovery(mail) -> netlify sends out reset mail
  • runRoutes triggers and... well, does nothing - which I guess is fine, just a heads up in the docs would've been nice
  • so I circumvented this by catching the recovery token myself and rerouting it to my route
  • there, recoverAccount(token) fetches a User object based on the verified token but performs no login, valid too
  • while this happens, the user can enter his new password and then submit
  • I'm now in possession of a regular User object, together with a valid JWT through the token and the new password - I should now be able to update the password via updateUser({ password }) - but because recoverAccount(token) didn't change any lib internal state, it throws the are you logged in error.
  • so I manually feed the token-verification User obj to the lib because after the state change, user is no longer null
  • it finally executes user!.update(fields).then(_setUser) in another effect where I have to ignore errors thrown from the lib - not sure why these are triggered

It's finally working but imo that's a mess. Am I doing something massively wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions