Home > Software design >  How to show the user their automatically generated password after social login?
How to show the user their automatically generated password after social login?

Time:08-11

I am faced with a beautiful enigma. In wordpress I have a widget that allows you to login with social login (google and facebook). When you login for the first time, the system automatically generates a password and username. This works well. I checked the database and password is correctly present as hashed.

Now, the problem is that if the user goes into profile settings and wants to change their password they have to enter current password first, but they can't know it since it was generated automatically.

I would like to give the user full control over the security of his account, so that he can change his password even if he is logged in with the social login.

So I foresee three possible solutions

  1. Allow the password to be changed without entering the current one (but it seems insecure).

  2. Email the automatically generated password (and I have no idea how I could do it). Or alternatively view it in the user's profile but I don't know how safe it is.

  3. Disable social login and rely on the classic registration :)

Has anyone faced a similar situation before? Can you clarify this with some standard method / practice ?

CodePudding user response:

You can allow the user to ask for a new password he/she specifies. The user will specify the password twice (password and confirm password fields) and then you:

  • encrypt the password the user asked for
  • store the encrypted value somewhere as password candidate (metadata, perhaps)
  • send an email to the user so he/she can confirm that he/she indeed asked for a password
  • once the user clicks on the link you have sent to him/her, replace the value of the password with the password candidate and remove the password candidate

Don't forget that the user is already logged in when he/she changes his/her password, adding an email validation to the password he/she asked for is pretty safe.

  • Related