mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-02-02 13:07:34 +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 @@ The addressed used to send this message is not a no-reply address. In fact, my n
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
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 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);
|
var result = await UserManager.CreateAsync(user, model.Password);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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>
|
<title>@ViewBag.Title • Project: Unite</title>
|
||||||
@Styles.Render("~/Content/css")
|
@Styles.Render("~/Content/css")
|
||||||
@Styles.Render("~/Content/bootstrap-theme.css")
|
@Styles.Render("~/Content/bootstrap-theme.css")
|
||||||
|
|
Loading…
Add table
Reference in a new issue