From 59673234655adb792e63acacf645a18e7794edcd Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 May 2017 20:26:45 -0400 Subject: [PATCH] api key revoking --- Project-Unite/Controllers/ManageController.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Project-Unite/Controllers/ManageController.cs b/Project-Unite/Controllers/ManageController.cs index 731c37f..243d2f0 100644 --- a/Project-Unite/Controllers/ManageController.cs +++ b/Project-Unite/Controllers/ManageController.cs @@ -168,6 +168,18 @@ public ActionResult Index(ApplicationUser model) return View(model); } + public ActionResult RevokeAPIKey(string id) + { + var db = new ApplicationDbContext(); + var usr = db.Users.FirstOrDefault(x => x.UserName == User.Identity.Name); + var key = db.OAuthTokens.FirstOrDefault(x => x.Id == id); + if (usr == null || key == null) + return new HttpStatusCodeResult(404); + db.OAuthTokens.Remove(key); + db.SaveChanges(); + return RedirectToAction("Index"); + } + // // POST: /Manage/RemoveLogin [HttpPost]