public void LoginException_with_message_and_inner_exception() { var e = new LoginException(_loginReason, _message, _innerException); Assert.AreEqual(_message, e.Message); Assert.AreSame(_innerException, e.InnerException); Assert.AreEqual(_loginReason, e.Reason); }
public void CheckLoginInfo(OperatorInfo optorInfo) { upYun = new UpYun(optorInfo.bucketName, optorInfo.operatorName, optorInfo.operatorPwd); upYun.setApiDomain(StrFormatUtil.FormatNetStr(optorInfo.netSelection)); try { double useSpace = upYun.getBucketUsage(); SFUSetting.Save(); SFULogger.DEFAULT.InfoFormat("操作员[{0}]登录成功.BucketName=[{1}],APINet=[{2}],BucketUsage=[{3}]", optorInfo.operatorName, optorInfo.bucketName, optorInfo.netSelection, useSpace); } catch (Exception ex) { upYun = null; if (ex.Message.Contains("401")) { string exceptionMsg = String.Format("操作员[{0}]登录失败.原因:登录信息填写有误,BucketName=[{1}],APINet=[{2}],ExceptionMsg=[{3}]", optorInfo.operatorName, optorInfo.bucketName, optorInfo.netSelection, ex); LoginException loginException = new LoginException(401, exceptionMsg); SFULogger.DEFAULT.Error(loginException.Message); throw loginException; } else { string exceptionMsg = String.Format("操作员[{0}]登录失败.原因:未知,BucketName=[{1}],APINet=[{2}],ExceptionMsg=[{3}]", optorInfo.operatorName, optorInfo.bucketName, optorInfo.netSelection, ex); LoginException loginException = new LoginException(0, exceptionMsg); SFULogger.DEFAULT.Error(loginException.Message); throw loginException; } } }
public void LoginException_with_message() { var e = new LoginException(_loginReason, _message); Assert.AreEqual(_message, e.Message); Assert.IsNull(e.InnerException); Assert.AreEqual(_loginReason, e.Reason); }
/// <summary> /// Gets the connections problem warning message internationalized. /// </summary> /// <returns>The connections problem warning.</returns> /// <param name="server">Tried server.</param> /// <param name="e">Returned Exception</param> public string GetConnectionsProblemWarning(LoginException e) { switch (e.Type) { case LoginExceptionType.PermissionDenied: return(Properties_Resources.LoginFailedForbidden); case LoginExceptionType.ServerNotFound: return(Properties_Resources.ConnectFailure); case LoginExceptionType.HttpsSendFailure: return(Properties_Resources.SendFailureHttps); case LoginExceptionType.NameResolutionFailure: return(Properties_Resources.NameResolutionFailure); case LoginExceptionType.HttpsTrustFailure: return(Properties_Resources.TrustFailure); case LoginExceptionType.Unauthorized: return(Properties_Resources.LoginFailedForbidden); default: return(string.Format( "{0}{1}{2}", e.Message, Environment.NewLine, string.Format(Properties_Resources.Sorry, Properties_Resources.ApplicationName))); } }
public void LoginException_with_message_and_inner_exception() { var e = new LoginException(_loginReason, _message, _innerException); Assert.AreEqual(_message, e.Message); Assert.AreSame(_innerException, e.InnerException); Assert.AreEqual(_loginReason, e.Reason); }
public void LoginException_with_message() { var e = new LoginException(_loginReason, _message); Assert.AreEqual(_message, e.Message); Assert.IsNull(e.InnerException); Assert.AreEqual(_loginReason, e.Reason); }
private async void loginButton_Clicked(object sender, EventArgs e) { if (!string.IsNullOrEmpty(userEmail_Login.Text) && !string.IsNullOrEmpty(userPassword_Login.Text)) { try { await Task.Run(() => LogInPoster()); //await Navigation.PushAsync(new Dashboard()); } catch (Exception LoginException) { await DisplayAlert("LoginException", LoginException.ToString(), "ok"); //Console.WriteLine("NextException : " + NextException); throw; } // After loggin in, we will fetch the account details of the user. try { await Task.Run(() => UserInfoFetcher()); } catch (Exception UserInfoFetchException) { //await DisplayAlert("UserInfoFetchException", UserInfoFetchException.ToString(), "ok"); //throw; await DisplayAlert("Server Sleeping", "Seems like our servers are sleeping. We will open a link and you should see when the server is up (generally takes 2-3 minutes. Try after that.", "Ok"); Device.OpenUri(new Uri("http://auth.fillip72.hasura-app.io/ui")); } // If cluster is sleeping and we get an WebException, we gotta wake the cluster up. if (ClusterSleeping) { await DisplayAlert("Server Sleeping", "Seems like our servers are sleeping. We will open a link and you should see when the server is up (generally takes 2-3 minutes. Try after that.", "Ok"); //Device.OpenUri(new Uri("http://auth.fillip72.hasura-app.io/ui")); await Task.Run(() => { Device.OpenUri(new Uri("http://auth.fillip72.hasura-app.io/ui")); }); return; } if (SignInStatus) { await Navigation.PushAsync(new Dashboard()); } else { await DisplayAlert("Failure!", message, "ok"); } } else { await DisplayAlert("Empty Fields", "Make Sure The Fields Are Filled.", "Ok"); } }
public string handleLoginExceptionAsync(HttpContext context, LoginException ex) { context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; if (ex.Message == "emailNotVerified") { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; } var message = _localizer[ex.Message]; return(message); }
public void TestLogin_WithRequestWithNoAccount_ShouldFail() { var request = new LoginMessages.Request() { Username = "******", Password = "******" }; var response = Sut.Handle(request); Assert.IsFalse(response.Success, "Should have failed!"); Assert.AreEqual(response.Exception.Message, LoginException.GetMessageFor(LoginExceptions.IncorrectCredentials), "Unexpected error message"); }
public JsonResult Login(string username, string password, string checkCode, bool keep = false) { JsonResult jsonResult; try { CheckInput(username, password); CheckCheckCode(username, checkCode); if (username.IndexOf(':') <= 0) { UserLoginIn(username, password, keep); SellerLoginIn(username, password, keep); ClearErrorTimes(username); jsonResult = Json(new { success = true, IsChildSeller = false }); } else { if (SellerLoginIn(username, password, keep) == null) { throw new LoginException("用户名和密码不匹配", LoginException.ErrorTypes.PasswordError); } ClearErrorTimes(username); jsonResult = Json(new { success = true, IsChildSeller = true }); } } catch (LoginException loginException1) { LoginException loginException = loginException1; int num = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = loginException.Message, errorTimes = num, minTimesWithoutCheckCode = 3, errorType = loginException.ErrorType }); } catch (HimallException himallException1) { HimallException himallException = himallException1; int num1 = SetErrorTimes(username); jsonResult = Json(new { success = false, msg = himallException.Message, errorTimes = num1, minTimesWithoutCheckCode = 3 }); } catch (Exception exception1) { Exception exception = exception1; int num2 = SetErrorTimes(username); Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误", errorTimes = num2, minTimesWithoutCheckCode = 3 }); } return(jsonResult); }
public JsonResult Index(string username, string password) { JsonResult jsonResult; try { CheckInput(username, password); UserMemberInfo userMemberInfo = ServiceHelper.Create <IMemberService>().Login(username, password); if (userMemberInfo == null) { throw new LoginException("用户名和密码不匹配", LoginException.ErrorTypes.PasswordError); } string str = UserCookieEncryptHelper.Encrypt(userMemberInfo.Id, "Mobile"); if (base.PlatformType != Himall.Core.PlatformType.WeiXin) { WebHelper.SetCookie("Himall-User", str, DateTime.MaxValue); } else { WebHelper.SetCookie("Himall-User", str); } jsonResult = Json(new { success = true, memberId = userMemberInfo.Id }); } catch (LoginException loginException1) { LoginException loginException = loginException1; jsonResult = Json(new { success = false, msg = loginException.Message }); } catch (HimallException himallException1) { HimallException himallException = himallException1; jsonResult = Json(new { success = false, msg = himallException.Message }); } catch (Exception exception) { Log.Error(string.Concat("用户", username, "登录时发生异常"), exception); jsonResult = Json(new { success = false, msg = "未知错误" }); } return(jsonResult); }
private void HandleError(LoginException exception) { _errorHandler.Handle(exception); }