0

I have a rails app and I have implemented devise, password resets etc that are built into devise.

I have a username field, however, I now need to allow the user to reset this too from the login page following the same flow as the way devise does password resets (recoverable).

I have a forget page where the user can select whether they have forgotten their password or username, the password flow is built-in devise, however, I'm unsure how to go about doing the username reset.

I have the views, but I need help with the backend so the flow I need is the user clicks that they have forgotten their username, they enter their email, they get sent a username reset email with a link with a generated token, clicking that link should send them to a page where they can reset there username.

Some images for reference

enter image description here enter image description here

Any help here would be great.

Ben Bagley
  • 733
  • 1
  • 9
  • 22
  • 1
    Wouldn't it be easier to allow users to log in with their username or their email? Then they could just log in via email and change the username in the settings. – spickermann Aug 24 '21 at 14:55
  • It might be easiest to just grab the related code from the devise Gem don't you think? then you could just implement this for username with the same process, could probably even find a way to tap into the devise methods so you aren;t duplicating a bunch of code. – Rockwell Rice Aug 24 '21 at 15:01
  • @spickermann This is what I was thinking, just letting the user login with both and just having a password reset in place. It'll save a bit of work too. – Ben Bagley Aug 24 '21 at 16:06

1 Answers1

0

@debugabug I think it can be an api call when user clicks on forget username or forget password. Having code common for both is better than to duplicate it. The API call is a POST call with email address in case of 'forget username' or username in case of 'forgot password'. Based on the incoming parameter, backend can decide the next workflow.

MrKickass
  • 93
  • 1
  • 13