public ActionResult Login(LoginVm loginVm) { this.SignOutCurrentUser(); if (this.ModelState.IsValid) { var verifyResult = this.userService.VerifyUser(loginVm.Account, loginVm.Password); if (verifyResult.Success) { IdentityTool.Authentication(this.AuthenticationManager, loginVm.RememberMe, loginVm.Account); var returnUrl = this.TempData["returnUrl"]?.ToString(); if (returnUrl == null || !this.Url.IsLocalUrl(returnUrl)) { return(this.RedirectToAction("Index", "Home")); } return(this.Redirect(returnUrl)); } this.TempData["alert"] = "帳號或密碼錯誤"; } else { this.SetModelStateError(); } return(this.View(loginVm)); }
public ActionResult Login(LoginVm loginVm) { // 登出當前使用者 if needed this.SignOutCurrentUser(); if (this.ModelState.IsValid) { var verifyResult = this.userService.VerifyUser(loginVm.Email, loginVm.Password); if (verifyResult.Success) { var user = this.userService.GetUserByEmail(loginVm.Email).Data; IdentityTool.Authentication( this.AuthenticationManager, loginVm.RememberMe, user.Id.ToString().ToUpper(), user.Email, user.UserName, new ClaimValueStruct { Field = IdentityFields.HeadPortraitPath.ToString(), Value = this.Url.Content(user.HeadPortraitPath) }); var returnUrl = this.TempData["returnUrl"]?.ToString(); if (returnUrl == null || !this.Url.IsLocalUrl(returnUrl)) { return(this.RedirectToAction("Index", "Home")); } return(this.Redirect(returnUrl)); } this.TempData["alert"] = "電子郵件或密碼錯誤"; } else { this.SetModelStateError(); } return(this.View(loginVm)); }