query other users' display names

This commit is contained in:
Michael 2017-05-03 09:08:57 -04:00
parent 96cde6df23
commit 0cdba811a6

View file

@ -213,7 +213,7 @@ public ActionResult GetPongHighscores()
}
public ActionResult GetDisplayName()
public ActionResult GetDisplayName(string id = "")
{
try
{
@ -221,7 +221,14 @@ public ActionResult GetDisplayName()
var user = ACL.GetUserFromToken(token);
if (user == null)
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
return Content(user.DisplayName);
if(string.IsNullOrWhiteSpace(id))
return Content(user.DisplayName);
var db = new ApplicationDbContext();
var uwithid = db.Users.FirstOrDefault(x => x.Id == id);
if (uwithid == null)
return new HttpStatusCodeResult(404);
return Content(uwithid.DisplayName);
}
catch
{