C
C#7mo ago
SNIPER512

Getting checked for username instead of email attribute in Identity framework in ASP.NET Core MVC

I wanted to ask the question here but the character limit won't let me. I have posted it on Stack Overflow. Please answer this. https://stackoverflow.com/questions/78583462/getting-checked-for-username-instead-of-email-attribute-in-identity-framework-in
Stack Overflow
Getting checked for username instead of email attribute in Identity...
I am trying to add a custom input field to my register page of Identity frame in ASP.NET Core MVC. By default, the AspNetUsers table in the database has a column UserName already it is passed Email...
1 Reply
Angius
Angius7mo ago
.PasswordSignInAsync() takes a string as the first value. It just so happens, that what gets passed to the first field in the login is named Email. Rename this property to PrettyGreenApple and it will work all the same. The names of variables passed into methods do not matter in the slightest. So just change the code to Login.cshtml.cs:
[Required]
public string UngaBungaScrungaName { get; set; }
[Required]
public string UngaBungaScrungaName { get; set; }
OnPostAsync method:
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();

if (ModelState.IsValid)
{
Console.WriteLine("UngaBungaScrungaName: " + Input.UngaBungaScrungaName);
Console.WriteLine("Password: " + Input.Password);

var result = await _signInManager.PasswordSignInAsync(Input.UngaBungaScrungaName, Input.Password, Input.RememberMe, lockoutOnFailure: false);

if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return LocalRedirect(returnUrl);
}
}
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();

if (ModelState.IsValid)
{
Console.WriteLine("UngaBungaScrungaName: " + Input.UngaBungaScrungaName);
Console.WriteLine("Password: " + Input.Password);

var result = await _signInManager.PasswordSignInAsync(Input.UngaBungaScrungaName, Input.Password, Input.RememberMe, lockoutOnFailure: false);

if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return LocalRedirect(returnUrl);
}
}
if it's something that bothers you
Want results from more Discord servers?
Add your server