public async Task<ActionResult> GetUsers() { AccountService service = new AccountService(); if (AccountService.AuthenticationToken.IsNullOrWhiteSpace()) { return Json(null, JsonRequestBehavior.AllowGet); } var models = await service.GetAllUsers(); return Json(models, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> JsonLogin(LoginModel model, string returnUrl) { if (ModelState.IsValid) { var accountService = new AccountService(); var success = await accountService.Login(model.UserName, model.Password); if (success) { FormsAuthentication.SetAuthCookie(model.UserName, false); } return RedirectToAction("Index", "Home"); } return View(model); }
public async Task<ActionResult> Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { var accountService = new AccountService(); var success = await accountService.Login(model.UserName, model.Password); if (success) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return RedirectToAction("Index", "Home"); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public async Task<ActionResult> Register(RegisterModel model) { if (ModelState.IsValid) { AccountService service = new AccountService(); string username = model.UserName; string password = model.Password; await service.Register(username, password, ""); return Json(new { success = true }); } return Json(new { success = false }); }