// GET: Admin public ActionResult Index() { UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>()); //ViewBag.LoginUser = userMgr.CurrentLoginUser; SystemStatus status = userMgr.GetLaji(); ViewBag.sysstatus = status; return View(userMgr.CurrentLoginUser); }
public ActionResult StartSystem() { UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>()); try { userMgr.StartSystem(); SystemStatus status = userMgr.GetLaji(); ViewBag.sysstatus = status; } catch(KMBitException kex) { ViewBag.msg = kex.Message; } catch { ViewBag.msg = "未知错误"; } return View("Index", userMgr.CurrentLoginUser); }
public ActionResult SetUserPassword(int userId) { SetPasswordViewModel model = new SetPasswordViewModel() { Id = userId }; UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>()); BUser user = userMgr.GetUserInfo(userId); if(user!=null) { ViewBag.User = user; return View(model); }else { ViewBag.Message = string.Format("编号为{0}的用户不存在",userId); return View("Error"); } }
public async Task<ActionResult> SetUserPassword(SetPasswordViewModel model) { UserManagement userMgr = new UserManagement(User.Identity.GetUserId<int>()); try { BUser user = userMgr.GetUserInfo(model.Id); if (ModelState.IsValid) { userMgr.DataProtectionProvider = Startup.DataProtectionProvider; bool ret = await userMgr.SetUserPassword(model.Id, model.NewPassword); //var result = await userMgr.AddPasswordAsync(User.Identity.GetUserId<int>(), model.NewPassword); if (!user.IsAdmin) { return RedirectToAction("Agencies"); } else { return RedirectToAction("Administrators"); } } else { ViewBag.User = user; return View(model); } } catch (KMBitException ex) { ViewBag.Message = ex.Message; } catch (Exception ex) { } return View("Error"); }
private ActionResult RedirectToLocal(string loginEmail,string returnUrl) { UserManagement umgt=new UserManagement(loginEmail); if (umgt.CurrentLoginUser != null) { Login_Log log = new Login_Log() { UserId = umgt.CurrentLoginUser.User.Id, LoginTime = KMBit.Util.DateTimeUtil.ConvertDateTimeToInt(DateTime.Now), LoginIP = Request.UserHostAddress }; if(!umgt.CurrentLoginUser.User.Enabled) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); log.Message = "账户被锁定,不能登陆系统,请联系管理员"; log.Succeed = false; umgt.CreateLoginLog(log); return RedirectToAction("LoginError", "Account",new { message= "账户被锁定,不能登陆系统,请联系管理员" }); } log.Message = ""; log.Succeed = true; umgt.CreateLoginLog(log); if (umgt.CurrentLoginUser.IsAdmin) { return RedirectToAction("Index", "Admin"); } else { return RedirectToAction("Index", "Agent"); } } if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } if (string.IsNullOrEmpty(loginEmail)) { return RedirectToAction("Index", "Home"); } return RedirectToAction("Index", "Home"); }