public ActionResult ModifyEmail(string email) { if (String.IsNullOrEmpty(email)) { return(Json(false)); } var u = CurrentUser; if (u != null) { u.UserMail = email; try { var count = BusinessHelper.UserHelper.Update(u, "UserMail"); if (count == 1) { OperLogHelper.AddOperLog($"{Username} 修改邮箱账号为{email} {DateTime.Now:yyyy-MM-dd HH:mm:ss}", OperLogModule.Account, Username); AuthFormService.SetCurrentUser(u); return(Json(true)); } } catch (Exception ex) { Logger.Error(ex); } } return(Json(false)); }
/// <summary> /// 退出登录 /// </summary> /// <returns></returns> public ActionResult Logout() { Logger.Info($"{Username} logout at {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); //logout AuthFormService.Logout(); //redirect to login page return(RedirectToAction("Login")); }
/// <summary> /// 退出登录 /// </summary> /// <returns></returns> public ActionResult Logout() { Logger.Info($"{Username} logout at {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); //logout AuthFormService.Logout(); //redirect to login page return(RedirectToAction("Index", new { area = "", controller = "Home" })); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var user = AuthFormService.GetCurrentUser(); if ((user == null) || !user.IsSuper) { filterContext.Result = new RedirectResult("~/Admin/Account/Login"); } base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.ActionDescriptor.IsDefined(typeof(NoPermissionRequiredAttribute), true)) { var user = AuthFormService.GetCurrentUser(); if (user == null) { filterContext.Result = new RedirectResult("~/Admin/Account/Login"); } } base.OnActionExecuting(filterContext); }
public ActionResult LogOn(LoginViewModel model) { if (ModelState.IsValid) { if (!ValidateValidCode(model.RecaptchaType, model.Recaptcha)) { return(Json("验证码有误")); } var u = new User { UserName = model.UserName, UserPassword = model.Password }; //是否登录成功逻辑添加 u = BusinessHelper.UserHelper.Login(u); if (u != null) { AuthFormService.Login(model.UserName, model.RememberMe); AuthFormService.SetCurrentUser(u); return(Json("")); } } return(Json("登录失败,用户名或密码错误")); }
public ActionResult ModifyPassword(ModifyPasswordViewModel model) { if (ModelState.IsValid) { if (CurrentUser == null) { return(Json(false)); } try { //判断原密码是否正确,原密码正确的情况才能修改密码 if (CurrentUser.UserPassword.Equals(SecurityHelper.SHA256_Encrypt(model.OldPassword))) { CurrentUser.UserPassword = SecurityHelper.SHA256_Encrypt(model.NewPassword); if (BusinessHelper.UserHelper.Update(CurrentUser, "UserPassword") > 0) { OperLogHelper.AddOperLog($"{Username} 修改密码 {DateTime.Now:yyyy-MM-dd HH:mm:ss}", OperLogModule.Account, Username); Logger.Info($"{Username} modify password at {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); //密码修改成功,需要重新登录 AuthFormService.Logout(); return(Json(true)); } } else { //原密码错误 } } catch (Exception ex) { Logger.Error(ex); } } return(Json(false)); }