public ActionResult Login(RegistrationLoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var memberLogin = new MemberLogin { NickName = model.LoginViewModel.NickName, Password = model.LoginViewModel.Password }; var member = _memberBusiness.MemberLogin(memberLogin); if (member.Success) { Response.CacheControl = "no-cache"; Response.AddHeader("Pragma", "no-cache"); Response.Expires = -1; DoLogin(member.Object, model.LoginViewModel.IsRemember); model.Url = string.Format("/{0}/{1}?login=true", RouteKeys.MemberController, RouteKeys.MemberProfile); return Json(model); } else { ModelState.AddModelError("error", member.Message); } } var returnModel = new RegistrationLoginViewModel() { LoginViewModel = model.LoginViewModel, RegistrationViewModel = new MemberRegisterViewModel(), Error = Errors(GetModelErrors()) }; return Json(returnModel); }
public ResultSet<Member> MemberLogin(MemberLogin member) { var result = new ResultSet<Member>(); Member loginMember = _memberRepository.MemberLogin(new Member() { Email = member.NickName }); if (loginMember == null) { result.Message = "Member not found"; return result; } if (string.IsNullOrEmpty(loginMember.PasswordHash) || !_hashProvider.VerifyHashString(member.Password, loginMember.PasswordHash, loginMember.PasswordSalt)) { result.Message = "Invalid password"; return result; } result.Object = loginMember; result.Message = "Operation success"; result.Success = true; return result; }