diff options
| author | Michael <[email protected]> | 2017-04-30 18:50:20 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-30 18:50:20 -0400 |
| commit | 99398e9326a393b8b3fcd72a8cc40f215d672672 (patch) | |
| tree | e365f2ff27e02c9e542b9080da368b005fdbf06f /Project-Unite/Controllers | |
| parent | a8cda15372949545826f934fb597536244553e18 (diff) | |
| download | project-unite-99398e9326a393b8b3fcd72a8cc40f215d672672.tar.gz project-unite-99398e9326a393b8b3fcd72a8cc40f215d672672.tar.bz2 project-unite-99398e9326a393b8b3fcd72a8cc40f215d672672.zip | |
email and sysname endpoints
Diffstat (limited to 'Project-Unite/Controllers')
| -rw-r--r-- | Project-Unite/Controllers/APIController.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/APIController.cs b/Project-Unite/Controllers/APIController.cs index 438050e..9d22a75 100644 --- a/Project-Unite/Controllers/APIController.cs +++ b/Project-Unite/Controllers/APIController.cs @@ -48,6 +48,60 @@ namespace Project_Unite.Controllers } + 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 |
