Closed ljosberinn closed 4 years ago
i dont think so. im not sure why i commented out that line in runRoutes. i think there was a PR complaining about this a while back but i dont think i accepted it. (edit: ah - i think this is because it’s better implemented in react-netlify-identity-widget? thats what i use anyway)
in any case - please feel free to PR what you think should be done - you have clearly done all the necessary research to fully understand this problem. I’m not currently active on this project right now but could very well come back to it at any time
Brainstorming here a little, let me know if this is over the top.
recoverAccount(token)
trigger _setUser
which performs a login (and also return the userObj to the dev, still)
runRoutes
return an obj of shape
{
token: string | undefined,
type: 'confirmation' | 'invite' | 'recovery' | 'email_change' | 'access' | 'confirmation' | undefined
}
which sets it to a new internal state param
which gets returned from the hook so developers can just use
const { replace } = useHistory();
const { param: { token, type }, user } = useIdentityContext();
if(token) { switch(type) { case 'recovery': replace('/settings/change-password'); break; // etc }
return null; }
Also, `recoverAccount(token)` and all other functions using `token` would need to consume said token and remove it afterwards.
this is an interesting approach! i was tempted to suggest returning an array of tokens, but realistically i dont think that is ever going to happen. so i think this works. if you'd like to try a PR, be my guest, if not i'll take a crack whenever i get back to this
Hi, so I've been tinkering with a reset-password route for a while and found this issue:
requestPasswordRecovery(mail)
-> netlify sends out reset mailrunRoutes
triggers and... well, does nothing - which I guess is fine, just a heads up in the docs would've been nicerecoverAccount(token)
fetches a User object based on the verified token but performs no login, valid tooupdateUser({ password })
- but becauserecoverAccount(token)
didn't change any lib internal state, it throws theare you logged in
error.user
is no longer nulluser!.update(fields).then(_setUser)
in another effect where I have to ignore errors thrown from the lib - not sure why these are triggeredIt's finally working but imo that's a mess. Am I doing something massively wrong here?