mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
Fix massive security bug with display names
This commit is contained in:
parent
147f266e68
commit
72feceb369
2 changed files with 16 additions and 0 deletions
|
@ -179,6 +179,16 @@ public async Task<ActionResult> Register(RegisterViewModel model)
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
using(var temp = new ApplicationDbContext())
|
||||
{
|
||||
if(temp.Users.FirstOrDefault(x=>x.UserName==model.Username) != null)
|
||||
{
|
||||
ModelState.AddModelError("Your display name is already taken.");
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, DisplayName = model.Username, Codepoints = 0, JoinedAt = DateTime.Now, MutedAt = DateTime.Now, BannedAt = DateTime.Now, LastLogin = DateTime.Now };
|
||||
var result = await UserManager.CreateAsync(user, model.Password);
|
||||
if (result.Succeeded)
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
@if(ViewBag.PageDescription != null)
|
||||
{
|
||||
<meta name="description" content="@ViewBag.PageDescription" />
|
||||
}
|
||||
|
||||
<title>@ViewBag.Title • Project: Unite</title>
|
||||
@Styles.Render("~/Content/css")
|
||||
@Styles.Render("~/Content/bootstrap-theme.css")
|
||||
|
|
Loading…
Reference in a new issue