private Exception CreateExceptionForFailedLoginAttempt(LoginResultType result, string usernameOrEmailAddress, string tenancyName) { switch (result) { case LoginResultType.Success: return(new ApplicationException("Don't call this method with a success result!")); case LoginResultType.InvalidUserNameOrEmailAddress: case LoginResultType.InvalidPassword: return(new UserFriendlyException(L("LoginFailed"), L("InvalidUserNameOrPassword"))); case LoginResultType.InvalidTenancyName: return(new UserFriendlyException(L("LoginFailed"), L("ThereIsNoTenantDefinedWithName{0}", tenancyName))); case LoginResultType.TenantIsNotActive: return(new UserFriendlyException(L("LoginFailed"), L("TenantIsNotActive", tenancyName))); case LoginResultType.UserIsNotActive: return(new UserFriendlyException(L("LoginFailed"), L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress))); case LoginResultType.UserEmailIsNotConfirmed: return(new UserFriendlyException(L("LoginFailed"), "Your email address is not confirmed. You can not login")); //TODO: localize message default: //Can not fall to default actually. But other result types can be added in the future and we may forget to handle it Logger.Warn("Unhandled login fail reason: " + result); return(new UserFriendlyException(L("LoginFailed"))); } }
public LoginResult(LoginResultType result, TUser user = null, Modulo modulo = null) { Result = result; Modulo = modulo; User = user; }
/// <summary> /// 登陆业务 /// </summary> /// <param name="UserNo">用户编号</param> /// <param name="UserName">用户名</param> /// <param name="Md5Pas">密码</param> /// <param name="LoginerInfo">登陆者信息</param> /// <param name="platform">平台code</param> /// <param name="info"></param> /// <returns></returns> public bool InsertLoginLog(LoginInfoForm loginForm, LoginResultType loginResultType) { Dictionary <string, object> keyValuePairs = new Dictionary <string, object>(); keyValuePairs.Add("UserName", loginForm.UserName); keyValuePairs.Add("MdfPas", loginForm.MdfPas); keyValuePairs.Add("LoginerInfo", loginForm.LoginerInfo); keyValuePairs.Add("Platform", loginForm.Platform); string message = JsonConvert.SerializeObject(keyValuePairs); UcLoginLog loginLog = new UcLoginLog() { id = AutoIDWorker.Example.GetAutoSequence(), Titile = LogTypeEumns.Login.GetEnumDescription(), Message = message, LogType = LogTypeEumns.Login.ToString(), RequestUser = loginForm.UserNo, RequestTime = DateTime.Now, InputTime = DateTime.Now, InputUser = loginForm.UserNo, Status = 0, HandleResult = (int)loginResultType, HandleMessage = loginResultType.GetEnumDescription(), HandleTime = DateTime.Now, HandleUser = HandleUserEumns.UserCenter.ToString(), ExpiresIn = 60 * 60 * 1000, }; return(this.Insert(loginLog) > 0); }
public Exception CreateExceptionForFailedLoginAttempt(LoginResultType result, string username, string tenancyName) { switch (result) { case LoginResultType.Success: return(new Exception("Don't call this method with a success result!")); case LoginResultType.InvalidUserName: case LoginResultType.InvalidPassword: return(new UserFriendlyException(L("登录失败"), L("用户名或密码不正确"))); case LoginResultType.InvalidTenancyName: return(new UserFriendlyException(L("登录失败"), L("账套{0}不存在", tenancyName))); case LoginResultType.TenantIsNotActive: return(new UserFriendlyException(L("登录失败"), L("此账套未启用或处于禁用状态,请联系客服15906863922", tenancyName))); case LoginResultType.UserIsNotActive: return(new UserFriendlyException(L("登录失败"), L("此用户已被禁用", username))); case LoginResultType.LockedOut: return(new UserFriendlyException(L("登录失败"), L("UserLockedOutMessage"))); case LoginResultType.UnknownExternalLogin: return(new UserFriendlyException("未知来源")); default: // Can not fall to default actually. But other result types can be added in the future and we may forget to handle it Logger.Warn("Unhandled login fail reason: " + result); return(new UserFriendlyException(L("LoginFailed"))); } }
// GET: Login private string LoginErrorMessage(LoginResultType type) { switch (type) { case LoginResultType.Success: return("登陆成功!"); case LoginResultType.InvalidAccount: return("用户名不正确!"); case LoginResultType.InvalidPassword: return("密码不正确!"); case LoginResultType.UserIsNotActive: return("用户没有激活!"); case LoginResultType.LoginOut: return("未知用户信息!"); case LoginResultType.LockedOut: return("用户被锁定!"); default: return("登陆失败!"); } }
public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { LoginResultType loginResult = dao.Login(model); if (loginResult.IsSuccess) { Session["Username"] = loginResult.CurrentUser.Username; Session["Role"] = loginResult.CurrentUser.Role; // lấy ra Danh sách sản phẩm muốn mua trong session Dictionary <int, ProductInWishListViewModel> wishList = Session["WishList"] != null ? Session["WishList"] as Dictionary <int, ProductInWishListViewModel> : new Dictionary <int, ProductInWishListViewModel>(); SuccessAndMsg getWishListInDb = wishListDAO.GetWishListInDb(loginResult.CurrentUser.Username); if (!getWishListInDb.IsSuccess) { // lấy ra Danh sách sản phẩm muốn mua thất bại TempData["Error"] = new ErrorViewModel(getWishListInDb.Message); return(RedirectToAction("SharedError", "Error")); } // gộp 2 Danh sách sản phẩm muốn mua SuccessAndMsg combineWishList = wishListDAO.CombineWishList(getWishListInDb.Value as Dictionary <int, ProductInWishListViewModel>, wishList); if (!combineWishList.IsSuccess) { // gộp 2 Danh sách sản phẩm muốn mua thất bại TempData["Error"] = new ErrorViewModel(combineWishList.Message); return(RedirectToAction("SharedError", "Error")); } // lưu Danh sách sản phẩm muốn mua mới vào Session Session["WishList"] = combineWishList.Value as Dictionary <int, ProductInWishListViewModel>; // chuyển đến trang được yêu cầu trước đó if (returnUrl != null) { return(Redirect(returnUrl)); } // chuyển về trang chủ nếu không có trang yêu cầu trước đó return(RedirectToAction("Index", "Home")); } else { ModelState.Clear(); ModelState.AddModelError("", loginResult.Message); } } else { // hiển thị thông báo lỗi cho người dùng ModelState.AddModelError("", ActionMessage.MissingOrInvalidInfo); } return(View()); }
public LoginResult(User user, string accountName, UserRegistType userRegistType) { _loginResult = LoginResultType.Success; _accountName = accountName; _user = user; _userRegistType = userRegistType; SetLoginResultMsg(); GenerateToken(); }
public LoginResult(LoginResultType result, TUser user, ClaimsPrincipal claimsPrincipal) { this.Result = result; this.User = user; this.ClaimsPrincipal = claimsPrincipal; if (claimsPrincipal != null) { this.Identity = claimsPrincipal.Identity as ClaimsIdentity; } }
public async Task TestLogin() { LoginResultType loginResultType = await serverProxy.LogIn(new LoginData() { Email = "email", Password = "******", SessionKey = "zaaaaaa" }); Assert.AreEqual("Success", loginResultType.LoginResult); }
/// <summary> /// Creates a UserLoginEventArg /// </summary> /// <param name="loginResultType">LoginResult type.</param> /// <param name="message">Message from server.</param> /// <returns>Populated UserLoginEventArg</returns> private UserLoginEventArgs createUserLoginEventArg( LoginResultType loginResultType, string message) { UserLoginEventArgs userLoginEventHandler = new UserLoginEventArgs() { LoginResultType = loginResultType, Message = message }; return(userLoginEventHandler); }
/// <summary> /// 平台登录业务 /// </summary> /// <param name="loginForm"></param> /// <returns></returns> public LoginResultType PlatformLogin(LoginInfoForm loginForm, ref UcUsers info) { LoginResultType loginResultType = this.Login(loginForm.UserName, loginForm.MdfPas, loginForm.LoginerInfo, loginForm.Password, ref info); if (loginResultType == LoginResultType.SUCCESS_LOGIN) { loginForm.UserNo = info.UserNo; } bool result = DataHandleManager.Instance().UcLoginLogHandle.InsertLoginLog(loginForm, loginResultType); return(loginResultType); }
public ActionResult <JsonResponses> Login([FromForm] LoginInfoForm loginInfoForm) { loginInfoForm.MdfPas = MD5Helper.GetMD5String(loginInfoForm.Password); UcUsers users = new UcUsers(); LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.PlatformLogin(loginInfoForm, ref users); if (LoginResult == LoginResultType.SUCCESS_LOGIN) { this.LoginAfterSuccess(users); return(new JsonResponses(JsonResponses.Success.code, LoginResult.ToString(), users)); } return(new JsonResponses(JsonResponses.Failed.code, LoginResult.ToString(), LoginResult)); }
public ActionResult <JsonResponses> LoginGet([FromQuery] LoginInfoForm loginInfoForm) { string MdfPas = MD5Helper.GetMD5String(loginInfoForm.Password); UcUsers users = new UcUsers(); LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.Login(loginInfoForm.UserName, MdfPas, loginInfoForm.LoginerInfo, loginInfoForm.Platform, ref users); if (LoginResult == LoginResultType.SUCCESS_LOGIN) { return(new JsonResponses(JsonResponses.Success.code, LoginResult.ToString(), LoginResult)); } return(new JsonResponses(JsonResponses.Failed.code, LoginResult.ToString(), LoginResult)); }
public void LoginSuccess(string userId, string accountName, LoginResultType loginResultResultType, string tokenId, DateTime loginTime) { string sqlStr1 = " UPDATE [dbo].[User] SET [LastLoginTime] = @DateTime ,[TokenId] = @TokenId WHERE Id = @UserId"; string sqlStr2 = " UPDATE [dbo].[UserLoginAttempts] SET LogoutTime = GETDATE(),IsOnline = @Outline WHERE UserId = @UserId AND IsOnline = @Online"; string sqlStr3 = " INSERT INTO[dbo].[UserLoginAttempts]([Id],[UserId],[TokenId],[AccountName],[ClientIpAddress],[BrowserInfo],[LoginTime],[LoginResult],[IsOnline] )" + " VALUES(@Id,@UserId,@TokenId, @AccountName,@ClientIpAddress,@BrowserInfo,@DateTime,@LoginResult,@IsOnline)"; using (var cn = LotteryDbConnection) { cn.Open(); using (var transaction = cn.BeginTransaction()) { try { cn.Execute(sqlStr1, new { UserId = userId, TokenId = tokenId, DateTime = loginTime }, transaction); cn.Execute(sqlStr2, new { UserId = userId, Outline = false, Online = true }, transaction); cn.Execute(sqlStr3, new { Id = Guid.NewGuid().ToString(), UserId = userId, TokenId = tokenId, AccountName = accountName, ClientIpAddress = IpHelper.GetClientIP(), BrowserInfo = Utils.GetBrowserInfo(), LoginResult = loginResultResultType, DateTime = loginTime, IsOnline = true, }, transaction); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
private string GetStatusMessage(LoginResultType loginResult) { switch (loginResult) { case LoginResultType.NoNetworkAvailable: return("StatusNoNetworkAvailable".GetLocalized()); case LoginResultType.UnknownError: return("StatusLoginFails".GetLocalized()); default: return(string.Empty); } }
public ActionResult <JsonResponses> CancelPlatform([FromForm] string UserNo) { if (!DataHandleManager.Instance().UcUsersHandle.CheckUserNoIsExist(UserNo)) { return(new JsonResponses(JsonResponses.FailedCode, LoginResultType.ERROR_USER_NOT_EXIST.ToString() , LoginResultType.ERROR_USER_NOT_EXIST)); } LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.CancelPlatform(UserNo); if (LoginResult == LoginResultType.SUCCESS_CANCEL) { return(new JsonResponses(JsonResponses.SuccessCode, LoginResult.ToString(), LoginResult)); } return(new JsonResponses(JsonResponses.FailedCode, LoginResult.ToString(), LoginResult)); }
/// <summary> /// 执行发布命令 /// </summary> /// <param name="project"></param> /// <param name="RequestUser"></param> /// <returns></returns> public bool RunPublishBat(PdProject project, string RequestUser) { if (project == null) { return(false); } string batPath = project.SourcePath + project.ProjectFile; if (File.Exists(batPath)) { FileInfo fileInfo = new FileInfo(batPath); if (!fileInfo.Exists) { return(false); } string enlistmentRoot = project.SourcePath; string workingDirectory = fileInfo.Directory.ToString(); string repoUrl = project.VersionUrl; string gitBinPath = project.MSBuildPath; GitBaseConfig config = new GitAuthConfig(enlistmentRoot, workingDirectory, repoUrl, gitBinPath); GitProcess process = config.CreateGitProcess(); int exitCode = -1; List <string> commandList = new List <string>(); commandList.Add(fileInfo.Name); List <string> reulit = this.Shell("cmd.exe", "/k ", 5 * 60 * 1000, fileInfo.Directory.ToString(), out exitCode, commandList.ToArray()); LoginResultType resultType = exitCode == 0 && reulit.Contains(" 0 个错误") ? LoginResultType.SUCCESS_PUBLISHCMD : LoginResultType.FAILED; string message = JsonConvert.SerializeObject(project); string HandleUser = ServerConstData.ServerName; int HandleResult = (int)resultType; string HandleMessage = resultType == LoginResultType.SUCCESS_PUBLISHCMD ? resultType.GetEnumDescription() : String.Join(";", reulit); DataHandleManager.Instance().UcLoginLogHandle. InsertCommonLog(RequestUser, message, LogTypeEumns.PublishCmd, HandleUser, HandleResult, HandleMessage); if (exitCode == 0 && reulit.Contains(" 0 个错误")) { return(true); } } else { DataHandleManager.Instance().UcLoginLogHandle. InsertPublishDeployGitLog(RequestUser, "batPath:" + batPath, ServerConstData.ServerName, 400, "文件不存在;"); } return(false); }
internal static async Task ShowLoginErrorAsync(LoginResultType loginResult) { switch (loginResult) { case LoginResultType.NoNetworkAvailable: await new MessageDialog( "DialogNoNetworkAvailableContent".GetLocalized(), "DialogAuthenticationTitle".GetLocalized()).ShowAsync(); break; case LoginResultType.UnknownError: await new MessageDialog( "DialogStatusUnknownErrorContent".GetLocalized(), "DialogAuthenticationTitle".GetLocalized()).ShowAsync(); break; } }
internal static async Task ShowLoginErrorAsync(LoginResultType loginResult) { var metroWindow = Application.Current.MainWindow as MetroWindow; switch (loginResult) { case LoginResultType.NoNetworkAvailable: await metroWindow.ShowMessageAsync(Resources.DialogNoNetworkAvailableContent, Resources.DialogAuthenticationTitle); break; case LoginResultType.UnknownError: await metroWindow.ShowMessageAsync(Resources.DialogAuthenticationTitle, Resources.DialogStatusUnknownErrorContent); break; } }
public void LoginFail(string userId, string accountName, LoginResultType loginResultType) { // string sqlStr1 = "UPDATE [App].[User] SET [LastLoginTime] = GETDATE() ,[TokenId] = @TokenId WHERE Id = @UserId"; string sqlStr = " INSERT INTO[dbo].[UserLoginAttempts]([Id],[UserId],[AccountName],[ClientIpAddress],[BrowserInfo],[LoginTime],[LoginResult],[IsOnline] )" + " VALUES(@Id,@UserId, @AccountName,@ClientIpAddress,@BrowserInfo, GETDATE(),@LoginResult,@IsOnline)"; using (var cn = LotteryDbConnection) { cn.Execute(sqlStr, new { Id = Guid.NewGuid().ToString(), UserId = userId, AccountName = accountName, ClientIpAddress = IpHelper.GetClientIP(), BrowserInfo = Utils.GetBrowserInfo(), IsOnline = false, LoginResult = loginResultType, }); } }
public ActionResult <JsonResponses> RegisterPlatfrom([FromForm] RegisterPlatformForm registerPlatform) { string MdfPas = MD5Helper.GetMD5String(registerPlatform.Password); registerPlatform.Password = MdfPas; if (String.IsNullOrEmpty(registerPlatform.Phone)) { registerPlatform.Phone = ConstData.DefaultNo.ToString(); } if (String.IsNullOrEmpty(registerPlatform.Email)) { registerPlatform.Email = ConstData.DefaultNo.ToString(); } LoginResultType LoginResult = DataHandleManager.Instance().UcUsersHandle.RegisterPlatform(registerPlatform); if (LoginResult == LoginResultType.SUCCESS_REGISTOR) { return(new JsonResponses(JsonResponses.SuccessCode, LoginResult.ToString(), registerPlatform)); } return(new JsonResponses(JsonResponses.FailedCode, LoginResult.ToString(), LoginResult)); }
/// <summary> /// 拉去项目代码 /// </summary> /// <param name="project"></param> /// <returns></returns> public bool GitProjectSourceCode(PdProject project, string RequestUser) { string enlistmentRoot = project.SourcePath; string workingDirectory = project.SourcePath; string repoUrl = project.VersionUrl; string gitBinPath = project.GitBinPath; GitBaseConfig config = new GitAuthConfig(enlistmentRoot, workingDirectory, repoUrl, gitBinPath); CloneService cloneService = new CloneService(config); ConfigResult configResult = cloneService.GetFromLocalConfig(GitConstant.GitCommandConfig.RemoteOriginUrl); string value = ""; string error = ""; Result result; if (configResult.TryParseAsString(out value, out error)) { ConfigResult configResult1 = cloneService.GetFromLocalConfig($"branch.{project.GitBranch}.remote"); if (configResult1.TryParseAsString(out value, out error) && !String.IsNullOrEmpty(value)) { result = cloneService.GitPull(); } else { result = cloneService.ForceCheckout(project.GitBranch); } } else { result = cloneService.GitClone(project.VersionUrl, project.GitBranch); } string message = JsonConvert.SerializeObject(project); string HandleUser = ServerConstData.ServerName; LoginResultType resultType = result.ExitCode == 0 ? LoginResultType.SUCCESS_PUBLISHGIT : LoginResultType.FAILED; int HandleResult = (int)resultType; DataHandleManager.Instance().UcLoginLogHandle. InsertPublishDeployGitLog(RequestUser, message, HandleUser, HandleResult, result.Output); return(result.ExitCodeIsSuccess); }
/// <summary> /// Thực hiện đăng nhập /// </summary> /// <param name="model"></param> /// <returns></returns> public LoginResultType Login(LoginViewModel model) { LoginResultType result = new LoginResultType(); string password = md5.GetMd5Hash(model.Password); var currUser = db.Users.FirstOrDefault(u => u.Username == model.Username && u.Password == password); // đăng nhập thành công if (currUser != null) { if (!currUser.Active) { // 1.3 Tài khoản bị khóa return(new LoginResultType(false, LoginResult.AccountBlocked)); } // đăng nhập thành công return(new LoginResultType(true, LoginResult.LoginSuccessful, currUser)); } // 1.1 Sai tên tài khoản hoặc mật khẩu return(new LoginResultType(false, LoginResult.WrongUsernameOrPassword)); }
public LoginResult(LoginResultType result, SysUserInfo user = null) { Result = result; User = user; }
public LoginResult(LoginResultType result, TUser user, ClaimsIdentity identity) { this.Result = result; this.User = user; this.Identity = identity; }
public void LoginResult(LoginResultType result) { this.Dispatcher.Invoke(() => { switch (result) { case LoginResultType.Success: { this.Hide(); break; } case LoginResultType.IncompleteOfArguments: { new PopupWindow(this, "失败", "参数不完整").ShowDialog(); break; } case LoginResultType.WrongPassword: { new PopupWindow(this, "失败", "密码错误").ShowDialog(); break; } case LoginResultType.UserNotExists: { new PopupWindow(this, "失败", "用户不存在").ShowDialog(); break; } case LoginResultType.NetworkTimedOut: { new PopupWindow(this, "失败", "网络超时").ShowDialog(); break; } default: { new PopupWindow(this, "失败", "未知错误").ShowDialog(); break; } } this.EnableAllInputs(true); }); }
public void LoginResult(LoginResultType result) { this.Dispatcher.Invoke(() => { var title = TranslationManager.GetManager.Localize("NotifyWindowTitle", "Unable to login in"); switch (result) { case LoginResultType.Success: { break; } case LoginResultType.IncompleteOfArguments: { this.PopupNotifyDialog(title, TranslationManager.GetManager.Localize("InvalidInput", "Password or username maybe invalid. Please check again.")); break; } case LoginResultType.WrongPassword: { this.PopupNotifyDialog(title, TranslationManager.GetManager.Localize("WrongPasswrd", "Password is incorrect.")); break; } case LoginResultType.UserNotExists: { this.PopupNotifyDialog(title, TranslationManager.GetManager.Localize("UserNotExists", "User name is not exists. Create user before log in.")); break; } case LoginResultType.NetworkTimedOut: { this.PopupNotifyDialog(title, TranslationManager.GetManager.Localize("NetWorkTimeOut", "Can not access server. Please check network.")); break; } default: { this.PopupNotifyDialog(title, TranslationManager.GetManager.Localize("UnknownLoginError", "Unknown fault caused unable to log in.")); break; } } this.EnableAllInputs(true); }); }
public LoginResult(LoginResultType result, Tenant tenant = null, User user = null) { Result = result; Tenant = tenant; User = user; }
public LoginResult(LoginResultType result) { Result = result; }
public LoginResult(LoginResultType result) { this.Result = result; this.User = null; }
public LoginResultDto(LoginResultType result) { Result = result; }
private void LoginFault(LoginResultType reason) { this.Engine.UiControl.LoginWindow.LoginResult(reason); }
public void Read(TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { AuthToken = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.String) { Certificate = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.String) { Verifier = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.String) { PinCode = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.I32) { Type = (LoginResultType)iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <param name="user"></param> public SysLoginResult(LoginResultType result, TUser user = null) { Result = result; User = user; }
public LoginResult(LoginResultType result, User user = null, ClaimsPrincipal claimsPrincipal = null) : base(result, user, claimsPrincipal) { }
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { AuthToken = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.String) { Certificate = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.String) { Verifier = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.String) { PinCode = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.I32) { Type = (LoginResultType)iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }