mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 11:21:47 -05:00
email and sysname endpoints
This commit is contained in:
parent
a8cda15372
commit
99398e9326
1 changed files with 54 additions and 0 deletions
|
@ -48,6 +48,60 @@ public ActionResult SetCodepoints(long id)
|
|||
}
|
||||
|
||||
|
||||
public ActionResult GetEmail()
|
||||
{
|
||||
try
|
||||
{
|
||||
string token = Request.Headers["Authentication"].Remove(0, 6);
|
||||
var user = ACL.GetUserFromToken(token);
|
||||
if (user == null)
|
||||
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
|
||||
return Content(user.Email);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult GetSysName()
|
||||
{
|
||||
try
|
||||
{
|
||||
string token = Request.Headers["Authentication"].Remove(0, 6);
|
||||
var user = ACL.GetUserFromToken(token);
|
||||
if (user == null)
|
||||
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
|
||||
return Content(user.SystemName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult SetSysName(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
string token = Request.Headers["Authentication"].Remove(0, 6);
|
||||
|
||||
var db = new ApplicationDbContext();
|
||||
var t = db.OAuthTokens.FirstOrDefault(x => x.Id == token);
|
||||
var user = db.Users.FirstOrDefault(x => x.Id == t.UserId);
|
||||
user.SystemName = id;
|
||||
db.SaveChanges();
|
||||
return new HttpStatusCodeResult(200);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ActionResult GetDisplayName()
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue