public Result <AuthenticateResult> AuthenticateUser(TUser user) { return(ServiceContext.ServiceDelegator.HandleSimpleTransactionEvent(nameof(User), (session) => { //return new SubjectOperator().AuthenticateUser(session, user); Result <AuthenticateResult> result = new Result <AuthenticateResult>(); result.Data = user.Authenticate(session); if (result.Data == AuthenticateResult.Success) { result.ResultCode = EResultCode.Success; } else { result.ResultCode = EResultCode.Failure; switch (result.Data) { case AuthenticateResult.UserNameUnexist: result.Message = "用户名不存在"; break; case AuthenticateResult.PasswordError: result.Message = "密码错误"; break; default: result.Message = "未支持该错误码:" + result.Data.ToString(); break; } } return result; })); }
public virtual ActionResult Login(Login model) { model.NeedsToBeActive = false; var membro = TUser.Authenticate(model); if (membro != null) { FormsAuthentication.SetAuthCookie(membro.Login, false); HttpContext.User = new GenericPrincipal(new GenericIdentity(membro.Login), new string[] { }); if (!string.IsNullOrWhiteSpace(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } TempData["Alerta"] = new Alert("success", "Bem-vindo" + " " + model.Username); return(RedirectToAction(MVC.Admin.Home.Index())); } else { membro = TUser.FindByUsername(model.Username); if (membro != null) { TempData["Alerta"] = new Alert("error", "Senha incorreta"); } TempData["Alerta"] = new Alert("error", "Usuário não existe"); return(View(model)); } }
public Report AuthenticateUser(TUser user) { return(ServiceBase.ServiceContext.ServiceDelegator.HandleTransactionEvent(DbConfigOfUser.DbName, (session) => { return user.Authenticate(session); })); }