Code Monkey home page Code Monkey logo

Comments (6)

ralscha avatar ralscha commented on July 24, 2024

I would implement a "password reset" or "forgot my password" function like this.

  • Add passwordResetToken (String) and passwordResetTokenValidUntil (Date) to the user entity
  • Add a link to the login page 'I forgot my password'.
    This link opens a page where the user can enter his username or email.
  • Add a password reset page where the user can enter the new password

The workflow then would go like this:

  1. User clicks on 'I forgot my password'
  2. The application opens a dialog where he can enter his username or email
  3. The server side code searches the user with username or email.
    When found it sets the passwordResetToken field to a random value and the
    field passwordResetTokenValidUntil to a date in the future. For example: current time + 1 hours
    When the application does not find the user it silently ignores the request and does nothing.
    The application should not show any error messages to the user.
  4. When the application finds the user in step 3 it sends an email to the user. The email text contains a
    link with the passwordResetToken in the url.
  5. The user clicks on the link and the application opens the password reset page where he can enter the password. The request of this page contains the new password and the token.
    The server checks if current time is less than passwordResetTokenValidUntil and if the token is equal to passwordResetToken.
    If both conditions are met it changes the password and sets passwordResetToken and passwordResetTokenValidUntil to null.

In a web application it's easy to implement a link in the email that opens the application and redirects to a specific page. I'm not exactly sure how to do that in a Cordova application. There is a Cordova plugin https://github.com/nordnet/cordova-universal-links-plugin that allows an application to use Universal Links / Deep Linking. If I understand this correctly this is a way to implement links that start a native application and trigger some action in the app. But I don't have any experience with that.

If you are looking for an example, the application https://github.com/ralscha/eds-starter6-mongodb uses this "password reset" workflow.


I always added two password fields to the sign up page of my previous applications.
But when you look at current sign up pages there are some that only have one password field.
https://twitter.com/signup?lang=en
https://www.facebook.com/r.php
https://www.instagram.com/accounts/emailsignup/?hl=en&signupFirst=true

I guess it's okay to only have one password field when the site has a "password reset" function.
When you mistype your password on the sign up page you can reset it.

from blog.

 avatar commented on July 24, 2024

Thanks a lot for the in depth answer. I think the tricky part will the universal linking into the app be. I will look into that when I find some spare time. Thanks again! 👍

from blog.

ralscha avatar ralscha commented on July 24, 2024

I just checked the password reset functionality of one of the apps I use a lot and they do it differently.
After you enter the email address they send you an email with the new password.
Then you can login with this password. But one thing I don't like is that they do not force the user to change the password immediately after he logged in. I guess that should be mandatory because the new password was sent over unsecure email.

from blog.

 avatar commented on July 24, 2024

Good point. The user should definitely be forced to change the password after the first successful login. Another idea was to sent a Code which the user has to enter in the app. But that involves Copy and Pasting and is maybe not considered user friendly.

from blog.

ralscha avatar ralscha commented on July 24, 2024

I guess that would not be bad when the code is not too complicated. I also had to remember the new password that they sent me.
When the link does not work this would be a good solution.

from blog.

 avatar commented on July 24, 2024

Oh yes right. Or also copy pasting it. Okay, thanks a lot!

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.