I am using ionic 3 and firebase for the backend.In my app I am trying to let users sign up with just username and password. Well firebase by default doesn't provide that option. So I am getting user's input as username (for example: 'mike123') then i add @myapp.com. so it looks like an email: 'mike123@myapp.com'. That is all fine, but a problem just came up when user's want to reset their passwords. Is it possible to let users type in any valid email address at the time they want to reset their password?.
Asked
Active
Viewed 57 times
2 Answers
1
If the email provided when sending the Reset Password request doesn't exist for any user, then it will fail.
In Android, calling sendPasswordResetEmail with a non-existing email, it would return a:
FirebaseAuthInvalidUserException: There is no user record corresponding to this identifier. The user may have been deleted.
You should ask for a valid email from the user and save their preferred username separately upon the user creation.
AL.
- 36,815
- 10
- 142
- 281
-
thx @AL. for the reply, in that case i cannot log in the user using username right..it has to be a valid email adress – Manas Jun 20 '17 at 02:58
-
Not necessarily. During login, you could just verify if the provided username has a corresponding email and then use it for login (see this [answer](https://stackoverflow.com/a/41201980/4625829)). However, I haven't tried this approach before (I just used email directly), so I'm not sure if it is safe to grant a read access to an unauthenticated user. – AL. Jun 20 '17 at 03:09
-
ic if i could check the username with the corresponding email that would be great..thxx for the suggestion @AL. – Manas Jun 20 '17 at 04:16
1
You can change the password of the user by https://firebase.google.com/docs/auth/admin/manage-users#update_a_user. Note that this is in the Firebase Admin SDK, so will require that you run code in a trusted environment, such as a server you control or Cloud Functions.
But faking username+password by faking an email address is non-ideal. I'd consider creating a custom auth provider for your needs.
Frank van Puffelen
- 565,676
- 79
- 828
- 807