Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dzhus/identity server update #105

Merged
merged 10 commits into from
Apr 20, 2021
6 changes: 6 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ public class User : IdentityUser

[DataType(DataType.DateTime)]
public DateTime LastLogin { get; set; }

public string LastName { get; set; }

public string MiddleName { get; set; }

public string FirstName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ public async Task ExternalLogin_ReturnsNotImplementedEx()
{
new TestCaseData(new RegisterViewModel()
{
Username = "Baron",
Email = "[email protected]",
PhoneNumber = "0502391222",
ReturnUrl = "Return url",
}),
new TestCaseData(new RegisterViewModel()
{
Username = "Baron",
Email = "[email protected]",
PhoneNumber = "0502391222",
ReturnUrl = "Return url2",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,16 @@ public async Task<IActionResult> Register(RegisterViewModel model)

var user = new User()
{
UserName = model.Username,
PhoneNumber = model.PhoneNumber,
CreatingTime = DateTime.Now,
UserName = model.Email,
FirstName = model.FirstName,
LastName = model.LastName,
MiddleName = model.MiddleName,
Email = model.Email,
PhoneNumber = model.PhoneNumber,
CreatingTime = DateTime.Now,
};
var result = await userManager.CreateAsync(user, model.Password);

var result = await userManager.CreateAsync(user, model.Password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what changed here?

if (result.Succeeded)
{
IdentityResult roleAssignResult = IdentityResult.Failed();
Expand Down Expand Up @@ -178,7 +182,12 @@ public async Task<IActionResult> Register(RegisterViewModel model)
else
{
foreach (var error in result.Errors)
{
{
if (error.Code == "DuplicateUserName")
{
error.Description = $"Email {error.Description.Substring(10).Split('\'')[0]} is alredy taken";
}

ModelState.AddModelError(string.Empty, error.Description);
}
}
Expand Down
Loading