How to implement reset password functionality in asp.net core for an user who didn't sign in using asp.net core identity

Sherpa 161 Reputation points
2024-03-26T04:27:01.2333333+00:00

I am working on a legacy Asp.Net Web Forms application which is nearly 18 years old. It uses a simple form based authentication where the users enter their username/password and the user is authenticated by matching the username/password saved in the Users table. Now I am tasked with creating a separate Asp.Net core 6.0 application with identity and razor pages which will be used to log into the above-mentioned old website and use two-factor authentication. I have created all the identity tables such as AspNetUsers using migrations. I also moved all the rows from the old Users table to this AspNetUsers table.

Now, when the old users try to log in, I will check that the username is present and it matches the old password they entered. There will be a separate column in the AspNetUsers table with the old password. After that, I want to direct them to the ChangePassword.cshtml razor page. The user probably should not be asked to enter the old password, since the cryptography used by the old application and the asp.net core identity will be different. When they enter the password and confirm the password textboxes, the password should be updated and they can now log in using the asp.net core identity. I would like to know how this can be achieved. Any help is greatly appreciated.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,166 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,256 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,026 Reputation points
    2024-03-26T15:58:13.95+00:00

    the common approach is to store the old password hash in the new schema. at login if the old hash is not null, compute the hash from the password and compare. if a match, clear the old ash, and update the password (compute) the new hash.

    if you do not have code to compute the hash, then you a conversion flag, if set, call a web service on the old site, that validates the user/password. if valid update the password on the new system.

    if you scaffold the razor login page, you can make the required changes.

    0 comments No comments