ResetPassword in .net core web api

Atilla Rüstəmli 40 Reputation points
2024-05-31T18:45:26.5333333+00:00

Hi, I'm currently working on a .NET core web API project and writing ResetPassword. The user wrote the email and front-end sent it to my ForgotPassword Endpoint, I checked the database and send the url with email and token in it to the user's email. This url is my ResetPassword(HttpGet) action's url and when user clicks on it it is going to my method . The ResetPassword(HttpGet) returns mail and token. I aslo have ResetPassword(HttpPost) action which requires NewPassword from UI and email and token from my ResetPassword(HttpGet) action. If everythink right the pasword will change. I think, The API part is right and as a back-end developer I dod everythink correct(according to the many tutorials and articles in the internet) but I can't understand the period between ResetPassword(HttpGet) and ResetPassword(HttpPost) actions. I mean, after clicking the link which were sent to the user's email, doesn't user have to go to the page where he will write his new password? And if User can go there and write new password , how front-end developer will get token and email from my ResetPassword(HttpGet) for sending me after user will click to the submit. Can anybody explain me, please? Because I'm working on it, almost 8 hours and haven't get any conclusion yet.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

Developer technologies | ASP.NET Core | Other
Developer technologies | ASP.NET Core | ASP.NET API
0 comments No comments

3 answers

Sort by: Newest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    3 deleted comments

    Comments have been turned off. Learn more

  2. AgaveJoe 31,706 Reputation points
    2024-06-01T01:50:20.0833333+00:00

    Ok, but after clicking to the link, it will go to my api's httpget method.

    No, the link should go to the Web application not Web API. If the browser is redirected to a Web API HTTP GET action, then the user we see a JSON response in browser not HTML.

    Was this answer helpful?


  3. Bruce (SqlWork.com) 85,416 Reputation points
    2024-05-31T20:23:48.54+00:00

    the email link should include the token value (typically base64url encrypted value). this is passed to the reset get. the get should render the token to a hidden field that will be included on the reset post. the post verifies the token value and if password meets complexity updates.

    typically the token contains the userid (so you know which user to update) and an expiration time, so the email link is valid for short amount of time.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.