I'm in final year at college and for my "project" module I've decided to make a Web App using Asp.Net Core as it's also one of the topics we study on the course. With little to no knowledge with C# and Asp.net core I'm running into problem after problem.
However at the minute I'm struggling with getting "forgotten password" to work.
We weren't allowed to use the inbuilt Authorisation start up (which I presume is Using.AspNetCore.Identity?)
Default_Context:
namespace Aspnetcorewebsite.Models
{
public class DefaultContext : DbContext
{
public DefaultContext(DbContextOptions<DefaultContext> options)
: base(options)
{
}
public static object Aspnetcorewebsite { get; internal set; }
public DbSet<Users> Users { get; set; }
}
}
Authentication Controller:
public class Authentication : Controller
{
private readonly DefaultContext _context;
public Authentication(DefaultContext context)
{
_context = context;
}
I've been following a guide on how to set this up and the following code has currently been written:
public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await userManager.FindByEmailAsync(model.Email);
if (user != null && await userManager.IsEmailConfirmedAsunc(user))
{
var token = await userManager.GeneratePasswordResetTokenAsync(User);
var passwordResetLink = Url.Action("ResetPassword", "Account",
new { email = model.Email, token = token }, Request.Scheme);
logger.Log(LogLevel.Warning, passwordResetLink);
return View("ForgottenPasswordConfirmation");
}
return View("ForgottenPasswordConfirmation");
}
return View(model);
}
However, due to not using AspNetCore.Identity I can't use userManager - I've got the following bit of code which I think I can work into the above code instead I'm just not 100% sure on how it would work
I've got the following bit of code which I think I can work into the above code instead I'm just not 100% sure on how it would work
I can't figure out what you are trying to do only from the codes you provide. Maybe you can first test your codes to check if it can work. If there are some problems, show us them, and provide us more information that can reproduce your problem.
Best Regards,
Jiadong Meng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
8 Posts
Forgotten Password
Apr 07, 2020 02:45 PM|binaarycode|LINK
I'm in final year at college and for my "project" module I've decided to make a Web App using Asp.Net Core as it's also one of the topics we study on the course. With little to no knowledge with C# and Asp.net core I'm running into problem after problem. However at the minute I'm struggling with getting "forgotten password" to work.
We weren't allowed to use the inbuilt Authorisation start up (which I presume is Using.AspNetCore.Identity?)
Default_Context:
Authentication Controller:
I've been following a guide on how to set this up and the following code has currently been written:
However, due to not using AspNetCore.Identity I can't use userManager - I've got the following bit of code which I think I can work into the above code instead I'm just not 100% sure on how it would work
Any guidance at this time is greatly appreciated.
Participant
1320 Points
491 Posts
Re: Forgotten Password
Apr 08, 2020 07:35 AM|jiadongm|LINK
Hi binaarycode,
I can't figure out what you are trying to do only from the codes you provide. Maybe you can first test your codes to check if it can work. If there are some problems, show us them, and provide us more information that can reproduce your problem.
Best Regards,
Jiadong Meng