Ejemplo n.º 1
0
 private void UserAuthControl_Load(object sender, EventArgs e)
 {
     ShowOptions = showOptions;
     LoginError  = loginError;
     buttonShowHideOptions.Text  = " " + (ShowOptions ? Resources.LOGIN_HIDE_OPTIONS : Resources.LOGIN_SHOW_OPTIONS);
     buttonShowHideOptions.Image = ShowOptions ? Properties.Resources.arrow_up_bw : Properties.Resources.arrow_down_bw;
 }
        //set new session to db
        private void Login(LoginRequest lr, string queueName)
        {
            if (string.IsNullOrEmpty(lr.Email) || string.IsNullOrEmpty(lr.Password))
            {
                BackError error = new BackError("Email or password is empty!");
                channel.BasicPublish(exchange: "", routingKey: queueName, basicProperties: null, body: error.Serializer());
                return;
            }
            User user = UserRepository.GetUserByEmail(lr.Email);

            if (user == null)
            {
                LoginError regError = new LoginError("Incorrect login or password!l");//incorrect login
                channel.BasicPublish(exchange: "", routingKey: queueName, basicProperties: null, body: regError.Serializer());
                return;
            }
            else
            {
                if (UserRepository.HashCode(lr.Password + user.Salt) == user.Password)
                {
                    string NewSessionId = Guid.NewGuid().ToString();
                    SessionRepository.SetUserSession(user.Id, NewSessionId);
                    LoginResponse logResponse = new LoginResponse(NewSessionId);
                    channel.BasicPublish(exchange: "", routingKey: queueName, basicProperties: null, body: logResponse.Serializer());
                    return;
                }
                else
                {
                    LoginError regError = new LoginError("Incorrect login or password!p");//incorrect password
                    channel.BasicPublish(exchange: "", routingKey: queueName, basicProperties: null, body: regError.Serializer());
                    return;
                }
            }
        }
Ejemplo n.º 3
0
 private void fireLoginFailed(LoginError error)
 {
     if (loginRegistrationListener != null)
     {
         loginRegistrationListener.onLoginFailed(error);
     }
 }
Ejemplo n.º 4
0
        public static string GetDescription(LoginError loginError)
        {
            string description;

            switch (loginError)
            {
            case LoginError.PeselIsNotValid:
                description = "Pesel is not valid";
                break;

            case LoginError.UserFirstNameIsTooShort:
                description = "Your first name is too short";
                break;

            case LoginError.UserFirstNameContainIllegalChars:
                description = "Your first name has illegal characters";
                break;

            case LoginError.UserLastNameIsTooShort:
                description = "Your last name is too short";
                break;

            case LoginError.UserLastNameContainIllegalChars:
                description = "Your last name has illegal characters";
                break;

            default:
                description = "Unknown error";
                break;
            }

            return(description);
        }
Ejemplo n.º 5
0
        public void TestUnsuccessfulLoginWithUncorrectEmail()
        {
            DefaultContractResolver contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new SnakeCaseNamingStrategy()
            };
            UserLogin userLogin = new UserLogin();

            userLogin.Email    = "111111";
            userLogin.Password = settings.TestUserPassword;
            string json = JsonConvert.SerializeObject(userLogin, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
                Formatting       = Formatting.Indented
            });
            Task <HttpResponse> resp       = PostHttpResponse("https://reqres.in/api/login", json);
            HttpResponse        result     = resp.Result;
            LoginError          loginError = JsonConvert.DeserializeObject <LoginError>(result.ResponseBody, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
                Formatting       = Formatting.Indented
            });

            Assert.AreEqual(400, result.StatusCode);
            Assert.AreEqual("user not found", loginError.Error);
        }
Ejemplo n.º 6
0
        public IActionResult Index()
        {
            if (UnitTest)
            {
                return(View(null));
            }

            LoginError model;

            /* Check for failed login attempt*/
            if (HttpContext.Session.TryGetValue("LoginError", out _))
            {
                string[] values = HttpContext.Session.GetString("LoginError").Split(";");
                HttpContext.Session.Remove("LoginError");
                model = new LoginError
                {
                    username       = values[0],
                    username_error = bool.Parse(values[1]),
                    password_error = bool.Parse(values[2])
                };
            }
            else
            {
                model = null;
            }
            localizer.SetLocale(HttpContext.Session.GetString("Language"));
            return(View(model));
        }
Ejemplo n.º 7
0
        private bool CheckSignupRespond(string respond)
        {
            bool isSucess;

            if (respond == "Email already exist")
            {
                SetSignupEmailError(LoginError.GetErrorValue(LoginError.Errors.EMAIL_ALREADY_EXIST));
                isSucess = false;
            }
            else if (respond == "Username already exist")
            {
                SetSignupUsernameError(LoginError.GetErrorValue(LoginError.Errors.USERNAME_ALREADY_EXIST));
                isSucess = false;
            }
            else if (respond == "Sucess")
            {
                isSucess = true;
                SetSignupSuccess(LoginError.GetErrorValue(LoginError.Errors.SIGNUP_SUCCESSFUL));
            }
            else
            {
                isSucess = false;
                SetSignupUsernameError("Unknow error");
            }
            return(isSucess);
        }
Ejemplo n.º 8
0
            public ErrorDialogFragment(LoginError e)
            {
                switch (e)
                {
                case LoginError.InvalidCredentials:
                    title      = Resource.String.LoginInvalidCredentialsDialogTitle;
                    message    = Resource.String.LoginInvalidCredentialsDialogText;
                    buttonText = Resource.String.LoginInvalidCredentialsDialogOk;
                    break;

                case LoginError.NetworkError:
                    title      = Resource.String.LoginNetworkErrorDialogTitle;
                    message    = Resource.String.LoginNetworkErrorDialogText;
                    buttonText = Resource.String.LoginNetworkErrorDialogOk;
                    break;

                case LoginError.SystemError:
                    title      = Resource.String.LoginSystemErrorDialogTitle;
                    message    = Resource.String.LoginSystemErrorDialogText;
                    buttonText = Resource.String.LoginSystemErrorDialogOk;
                    break;

                case LoginError.NoAccount:
                    title      = Resource.String.LoginNoAccountDialogTitle;
                    message    = Resource.String.LoginNoAccountDialogText;
                    buttonText = Resource.String.LoginNoAccountDialogOk;
                    break;

                case LoginError.SignupFailed:
                    title      = Resource.String.LoginSignupFailedDialogTitle;
                    message    = Resource.String.LoginSignupFailedDialogText;
                    buttonText = Resource.String.LoginSignupFailedDialogOk;
                    break;
                }
            }
Ejemplo n.º 9
0
        /// <summary>
        /// The read.
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="packet">
        /// </param>
        public static void Read(Client client, byte[] packet)
        {
            LogUtil.Debug(DebugInfoDetail.Network, "\r\nReceived:\r\n" + HexOutput.Output(packet));

            MemoryStream m_stream = new MemoryStream(packet);
            BinaryReader m_reader = new BinaryReader(m_stream);

            // now we should do password check and then send OK or Error
            // sending OK now
            m_stream.Position = 8;

            short  userNameLength = IPAddress.NetworkToHostOrder(m_reader.ReadInt16());
            string userName       = Encoding.ASCII.GetString(m_reader.ReadBytes(userNameLength));
            short  loginKeyLength = IPAddress.NetworkToHostOrder(m_reader.ReadInt16());
            string loginKey       = Encoding.ASCII.GetString(m_reader.ReadBytes(loginKeyLength));

            LoginEncryption loginEncryption = new LoginEncryption();

            if (loginEncryption.IsValidLogin(loginKey, client.ServerSalt, userName))
            {
                client.IsBot = true;
                byte[] chars = AccountCharacterList.Create(userName);
                LogUtil.Debug(DebugInfoDetail.Network, "\r\nReceived:\r\n" + HexOutput.Output(chars));

                client.Send(chars);
            }
            else
            {
                byte[] loginerr = LoginError.Create();
                client.Send(loginerr);
                client.Server.DisconnectClient(client);
            }
        }
Ejemplo n.º 10
0
 private void resetLoginProccesss(bool isFailed, LoginError loginError = LoginError.None)
 {
     registrationProcess.MoveNext(RegisterCommands.Clear);
     if (isFailed)
     {
         fireLoginFailed(LoginError.RegistrationFailed);
     }
 }
Ejemplo n.º 11
0
        // Logs in using email and password
        public async void Login(string email, string password, string code)
        {
            client.DefaultRequestHeaders.Remove("Referer");
            client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/login");

            var log = new LoginRequest(email, password);

            var content = new JsonContent(log);

            var response = await client.PostAsync(DiscordAPI.loginEndpoint, content);

            var ree = await response.Content.ReadAsStringAsync();

            var responseObject = Serializer.Parse <LoginPayload>(ree);

            client.DefaultRequestHeaders.Remove("Referer");
            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                if (responseObject.Errors != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Wrong email or password"));
                }
                if (responseObject.CaptchaKey != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Log in and out of Discord and solve the captcha."));
                }
            }
            else if (response.IsSuccessStatusCode)
            {
                if (string.IsNullOrEmpty(responseObject.Token))
                {
                    if (!string.IsNullOrEmpty(responseObject.Ticket))
                    {
                        client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/login");
                        // Adds a delay so we don't get ratelimited
                        //await Task.Delay(1500);
                        LoginMfa(responseObject.Ticket, code);
                    }
                    else
                    {
                        LoginError?.Invoke(new LoginErrorEventArgs(this, "Unknown error"));
                        Debug.WriteLine("Unknown error");
                    }
                }
                else
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(responseObject.Token);
                    client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");
                    DataStore.SaveToken(responseObject.Token);
                    Ready?.Invoke(new ReadyEventArgs(this));
                }
            }
            else
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Error " + response.StatusCode));
                Debug.WriteLine("Error " + response.StatusCode);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserStruct"/> struct.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <remarks>Documented by Dev05, 2009-03-04</remarks>
 private UserStruct(string username)
 {
     UserName           = username;
     Password           = string.Empty;
     Identifier         = string.Empty;
     AuthenticationType = null;
     CloseOpenSessions  = false;
     LastLoginError     = LoginError.NoError;
 }
Ejemplo n.º 13
0
 public void onLoginFailed(LoginError loginError)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         load.IsVisible            = false;
         stack_registrar.IsVisible = true;
         registration_status.Text  = "Failed";
         this.populateLoginFields();
     });
 }
Ejemplo n.º 14
0
 public ApiContext()
 {
     baseUri           = new Uri("https://reqres.in/api/");
     response          = new HttpResponseMessage();
     user              = new User();
     userListResponse  = new UserListResponse();
     userQueryResponse = new UserQueryResponse();
     loginToken        = new LoginToken();
     loginError        = new LoginError();
 }
Ejemplo n.º 15
0
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            if (AccInBox.Text.Length == 0)
            {
                LoginError.SetError(AccInBox, "Not Null!!");
            }
            if (PwdInBox.Text.Length == 0)
            {
                LoginError.SetError(PwdInBox, "空のインプットができません");
            }
            //else
            //{
            //    try
            //    {
            //        int i = Int32.Parse(PwdBox.Text.Trim());
            //        LoginError.SetError(PwdBox,"");
            //    }
            //    catch
            //    {
            //        LoginError.SetError(PwdBox,"数字のパスワードを入力してください");
            //    }
            //}

            //if (AccInBox.Text == "vickerszhu" && PwdInBox.Text == "database")
            //{
            //    this.AcceptButton = ConnectButton;
            //    sqlkey = "server=.;database=Vickers;uid=" + AccInBox.Text + ";pwd=" + PwdInBox.Text + ";";
            //    MainInterface f = new MainInterface(sqlkey);
            //    f.Show();
            //    this.Hide();
            //}
            if (PwdInBox.Text.Trim() == identi_tools.UsersSavedBuyers(dttb, AccInBox.Text.Trim()))
            {
                initConn.Close();
                this.AcceptButton = ConnectButton;
                sqlkey            = "server=.;database=Vickers;uid=" + AccInBox.Text + ";pwd=" + PwdInBox.Text + ";";
                MainUser          = AccInBox.Text.Trim();
                MainInterface f = new MainInterface(sqlkey);
                initConn.Close();
                f.Show();
                this.Hide();
            }
            else if (PwdInBox.Text == identi_tools.UsersSavedSellers(dttb, AccInBox.Text.Trim()))
            {
                initConn.Close();
                this.AcceptButton = ConnectButton;
                sqlkey            = "server=.;database=Vickers;uid=" + AccInBox.Text + ";pwd=" + PwdInBox.Text + ";";
                MainUser          = AccInBox.Text.Trim();
                SellerWorkstageInterface f = new SellerWorkstageInterface(sqlkey);
                initConn.Close();
                f.Show();
                this.Hide();
            }
        }
Ejemplo n.º 16
0
        private bool CheckLoginRespond(string respond)
        {
            bool isSucess;

            if (respond == "LOGIN SUCESS")
            {
                isSucess = true;
            }
            else
            {
                SetLoginFail(LoginError.GetErrorValue(LoginError.Errors.LOGIN_FAILED));
                isSucess = false;
            }
            return(isSucess);
        }
Ejemplo n.º 17
0
        private async Task AddLoginAttemptAsync(LoginError loginError, int userId, ConnectionInfo connectionInfo)
        {
            var loginAttempt = new LoginAttempt
            {
                FromIp  = connectionInfo.IpAddress.ToString(),
                Date    = DateTimeOffset.Now,
                Success = loginError == LoginError.None,
                Reason  = loginError.ToString(),
                UserId  = userId,
                Browser = connectionInfo.BrowserInfo.BrowserFamily,
                Device  = connectionInfo.BrowserInfo.DeviceFamily,
                Os      = connectionInfo.BrowserInfo.OsFamily
            };

            await _loginAttemptsRepositoryService.AddLoginAttemptsAsync(loginAttempt);
        }
Ejemplo n.º 18
0
        public static string Login(string userName, string password)
        {
            OpenChannel();
            Report.log(DeviceToReport.Client_Proxy, LogLevel.Information, $"Channel opened for client {userName}");
            bool isFault = false;

            try
            {
                LoginError error = proxy.Login(userName, password);
                if (error == LoginError.NoError)
                {
                    StartTimer();
                    Report.log(DeviceToReport.Client_Proxy, LogLevel.Information, $"Client {userName} connected");
                }
                else
                {
                    Report.log(DeviceToReport.Client_Proxy, LogLevel.Information, $"Client {userName} was not connected");
                }

                //Check connection to server every _checkConnectionSeconds

                return(GenerateErrorString(error));
            }
            catch (EndpointNotFoundException)
            {
                isFault = true;
                string message = "Connection error - Unable to connect to server";
                Report.log(DeviceToReport.Client_Proxy, LogLevel.Exception, message);
                throw new EndpointNotFoundException(message);
            }
            catch (Exception e)
            {
                isFault = true;
                Report.log(DeviceToReport.Client_Proxy, LogLevel.Exception, e.Message);
                throw e;
            }
            finally
            {
                if (isFault)
                {
                    factory.Abort();
                    Report.log(DeviceToReport.Client_Proxy, LogLevel.Information, $"Channel closed for client {userName} after exception");
                    OpenChannel();
                    Report.log(DeviceToReport.Client_Proxy, LogLevel.Information, $"Channel opened for client {userName} after exception");
                }
            }
        }
Ejemplo n.º 19
0
        private bool ValidateSignup(string username, string email, string password, string confirmation)
        {
            bool isValid = true;

            if (!Regex.IsMatch(username, @"^[a-zA-Z0-9]*$"))
            {
                SetSignupUsernameError(LoginError.GetErrorValue(LoginError.Errors.USERNAME_INVALID_FORMAT));
                isValid = false;
            }
            else if (username.Length < 5)
            {
                SetSignupUsernameError(LoginError.GetErrorValue(LoginError.Errors.USERNAME_TOO_SHORT));
                isValid = false;
            }
            else if (username.Length > 30)
            {
                SetSignupUsernameError(LoginError.GetErrorValue(LoginError.Errors.USERNAME_TOO_LONG));
                isValid = false;
            }

            if (password.Length < 6)
            {
                SetSignupPasswordError(LoginError.GetErrorValue(LoginError.Errors.PASSWORD_TOO_SHORT));
                ResetPasswordFields();
                isValid = false;
            }
            else if (password != confirmation)
            {
                SetSignupPasswordError(LoginError.GetErrorValue(LoginError.Errors.PASSWORD_DONT_MATCH));
                ResetPasswordFields();
                isValid = false;
            }
            else if (!Regex.IsMatch(password, "[0-9]{1}") || !Regex.IsMatch(password, "[A-Z]{1}"))
            {
                SetSignupPasswordError(LoginError.GetErrorValue(LoginError.Errors.PASSWORD_INVALID_FORMAT));
                ResetPasswordFields();
                isValid = false;
            }

            if (!CheckValidEmail(email))
            {
                SetSignupEmailError(LoginError.GetErrorValue(LoginError.Errors.EMAIL_INVALID_FORMAT));
                isValid = false;
            }

            return(isValid);
        }
Ejemplo n.º 20
0
        private void txtIngresar_Click(object sender, EventArgs e)
        {
            SingletonIdioma.intance.CambiarIdioma((Idioma)cbIdioma.SelectedItem);
            LoginComponent loginComponent = new LoginComponent();
            Usuarios       usuarios       = new Usuarios();

            usuarios.UserName = txtUsuario.Text;
            usuarios.Email    = txtUsuario.Text;
            usuarios.Password = txtContraseña.Text;

            if (VerificarCampos(usuarios))
            {
                LoginError loginError = new LoginError();
                loginError = loginComponent.VerificarLogin(usuarios);
                if (loginError.error == "")
                {
                    UsuarioRolesComponent usuarioRoles = new UsuarioRolesComponent();

                    foreach (var item in usuarioRoles.ReadByUsuario(SessionManager.instance.GetUSuario().Id))
                    {
                        if (item.roles.name == "Administrador")
                        {
                            frmAdministrador uservicios = new frmAdministrador();
                            uservicios.ShowDialog();
                            listarIdioma();
                        }
                        if (item.roles.name == "Alumno")
                        {
                            frmAlumnoIndex uservicios = new frmAlumnoIndex();
                            uservicios.ShowDialog();
                            listarIdioma();
                        }
                        if (item.roles.name == "Maestro")
                        {
                            frmMaestro uservicios = new frmMaestro();
                            uservicios.ShowDialog();
                            listarIdioma();
                        }
                    }
                }
                else
                {
                    lbError.Text = loginError.error;
                }
            }
        }
Ejemplo n.º 21
0
        private void OnError(object sender, ErrorEventArgs e)
        {
            Console.WriteLine("Error");
            Console.WriteLine(e.ToString());

            if (e.Exception.Message.Contains("401") && e.Exception.Message.Contains("HTTP"))
            {
                LoginError?.Invoke();
                Disconnect();
                return;
            }

            if (!clean)
            {
                CreateWebsocket();
            }
        }
Ejemplo n.º 22
0
        private bool ValidateLogin(string email, string password)
        {
            bool isValid = true;

            if (!CheckValidEmail(email))
            {
                SetLoginEmailError(LoginError.GetErrorValue(LoginError.Errors.EMAIL_INVALID_FORMAT));
                isValid = false;
            }
            else if (!Regex.IsMatch(password, "[0-9]{1}") || !Regex.IsMatch(password, "[A-Z]{1}"))
            {
                SetLoginPasswordError(LoginError.GetErrorValue(LoginError.Errors.PASSWORD_INVALID_FORMAT));
                isValid = false;
            }

            return(isValid);
        }
Ejemplo n.º 23
0
        public IActionResult Index([FromQuery] QueryParams query)
        {
            SetLanguage(query);
            var le    = GetErrors();
            var model = new ErrorViewModel()
            {
                Parameters = query
            };

            SetNavigation(le, model);

            if (query.errorurl_code + "" == "" | (query.errorurl_code + "" == "ERRORURL_CODE"))
            {
                //Get all errors
                model.LoginError = le.Errors.ToList();
            }
            else
            {
                //Get specific error
                LoginError e = le.Errors.Where(e => e.Type == query.errorurl_code).SingleOrDefault();
                if ((query.errorurl_ctx + "" != "" && (query.errorurl_ctx + "").ToUpper() != "errorurl_ctx"))
                {
                    if (e.context != null)
                    {
                        var ctx = e.context.Where(i => i.Identifiers.Contains(query.errorurl_ctx)).SingleOrDefault();
                        if (ctx != null)
                        {
                            e.Header = ctx.Header;
                            e.Body   = ctx.Body;
                        }
                    }
                }
                //ToDo handle if e is null
                model.LoginError = new List <LoginError>()
                {
                    e
                };
            }
            Footer = le.Common.Footer;
            Title  = model.LoginError.First().Header;
            return(View(model));
        }
Ejemplo n.º 24
0
        // Login using token, sets Authorization header and tests if the token is valid by sending a GET request to user API endpoint
        public async void Login(string token)
        {
            client.DefaultRequestHeaders.Remove("Referer");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token);
            client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");

            var response = await client.GetAsync(DiscordAPI.userEndpoint);

            Debug.WriteLine($"{response.StatusCode}: {await response.Content.ReadAsStringAsync()}");
            if (response.StatusCode == HttpStatusCode.Unauthorized)
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Invalid token"));
                Debug.WriteLine("Invalid token");
            }
            else if (response.IsSuccessStatusCode)
            {
                DataStore.SaveToken(token);
                Ready?.Invoke(new ReadyEventArgs(this));
            }
        }
Ejemplo n.º 25
0
        public async void LoginMfa(string ticket, string code)
        {
            var log = new MfaRequest(code, ticket);

            var content = new JsonContent(log);

            var response = await client.PostAsync(DiscordAPI.mfaEndpoint, content);

            var responseObject = Serializer.Parse <MfaPayload>(await response.Content.ReadAsStringAsync());

            client.DefaultRequestHeaders.Remove("Referer");

            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                if (responseObject.Message != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, responseObject.Message));
                    Debug.WriteLine(responseObject.Message);
                }
            }
            else if (response.IsSuccessStatusCode)
            {
                if (string.IsNullOrEmpty(responseObject.Token))
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Unknown error"));
                    Debug.WriteLine("Unknown error");
                }
                else
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(responseObject.Token);
                    client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");
                    DataStore.SaveToken(responseObject.Token);
                    Ready?.Invoke(new ReadyEventArgs(this));
                }
            }
            else
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Error " + response.StatusCode));
                Debug.WriteLine("Error " + response.StatusCode);
            }
        }
Ejemplo n.º 26
0
        private UserStruct?GetInvalidListUser2(UserStruct userStr, ConnectionStringStruct con)
        {
            if (!invalidListUser2Received)
            {
                invalidListUser2Received = true;
            }
            else
            {
                LoginError err = userStr.LastLoginError;
                if (err == LoginError.WrongAuthentication)
                {
                    throw new NoValidUserException();
                }
                else
                {
                    throw new Exception("Invalide user not recognised");
                }
            }

            return(new UserStruct("alex", UserAuthenticationTyp.ListAuthentication));
        }
Ejemplo n.º 27
0
        private UserStruct?GetInvalidFormsUser2(UserStruct userStr, ConnectionStringStruct con)
        {
            if (!invalidFormsUser2Received)
            {
                invalidFormsUser2Received = true;
            }
            else
            {
                LoginError err = userStr.LastLoginError;
                if (err == LoginError.WrongAuthentication)
                {
                    throw new NoValidUserException();
                }
                else
                {
                    throw new Exception("Invalide authentication not recognised");
                }
            }

            return(new UserStruct("testuser", string.Empty, UserAuthenticationTyp.FormsAuthentication, true));
        }
Ejemplo n.º 28
0
        private UserStruct?GetLoginErrorMethod(UserStruct u, ConnectionStringStruct c)
        {
            if (!userSubmitted)
            {
                userSubmitted = true;
                UserStruct user = MLifterTest.DAL.TestInfrastructure.GetTestUser(u, c).Value;
                user.CloseOpenSessions = false;
                return(user);
            }

            LoginError err = u.LastLoginError;

            if (err == LoginError.AlreadyLoggedIn)
            {
                throw new DoubleLoginException();
            }
            else
            {
                throw new Exception("The supposed Error 'AlreadyLoggedIn' hasn't occurred!");
            }
        }
Ejemplo n.º 29
0
        private UserStruct?GetInvalidLdUser(UserStruct userStr, ConnectionStringStruct con)
        {
            if (!invalidLdUserReceived)
            {
                invalidLdUserReceived = true;
            }
            else
            {
                LoginError err = userStr.LastLoginError;
                if (err == LoginError.ForbiddenAuthentication)
                {
                    throw new NoValidUserException();
                }
                else
                {
                    throw new Exception("Invalide authentication not recognised");
                }
            }

            return(new UserStruct("invalid", UserAuthenticationTyp.LocalDirectoryAuthentication));
        }
Ejemplo n.º 30
0
        private UserStruct?GetInvalidFormsUser3(UserStruct userStr, ConnectionStringStruct con)
        {
            if (!invalidFormsUser3Received)
            {
                invalidFormsUser3Received = true;
            }
            else
            {
                LoginError err = userStr.LastLoginError;
                if (err == LoginError.InvalidUsername || err == LoginError.InvalidPassword)
                {
                    throw new NoValidUserException();
                }
                else
                {
                    throw new Exception("Invalide user not recognised");
                }
            }

            System.Security.SecureString SecurePassword = new System.Security.SecureString();
            return(new UserStruct("alex", string.Empty, UserAuthenticationTyp.FormsAuthentication, true));
        }
Ejemplo n.º 31
0
 public LoginException(LoginError er)
 {
     _er = er;
 }
Ejemplo n.º 32
0
 public ErrorDialogFragment (LoginError e)
 {
     switch (e) {
     case LoginError.InvalidCredentials:
         title = Resource.String.LoginInvalidCredentialsDialogTitle;
         message = Resource.String.LoginInvalidCredentialsDialogText;
         buttonText = Resource.String.LoginInvalidCredentialsDialogOk;
         break;
     case LoginError.NetworkError:
         title = Resource.String.LoginNetworkErrorDialogTitle;
         message = Resource.String.LoginNetworkErrorDialogText;
         buttonText = Resource.String.LoginNetworkErrorDialogOk;
         break;
     case LoginError.SystemError:
         title = Resource.String.LoginSystemErrorDialogTitle;
         message = Resource.String.LoginSystemErrorDialogText;
         buttonText = Resource.String.LoginSystemErrorDialogOk;
         break;
     case LoginError.NoAccount:
         title = Resource.String.LoginNoAccountDialogTitle;
         message = Resource.String.LoginNoAccountDialogText;
         buttonText = Resource.String.LoginNoAccountDialogOk;
         break;
     case LoginError.SignupFailed:
         title = Resource.String.LoginSignupFailedDialogTitle;
         message = Resource.String.LoginSignupFailedDialogText;
         buttonText = Resource.String.LoginSignupFailedDialogOk;
         break;
     }
 }
Ejemplo n.º 33
0
	public void LoginFailed (LoginError error, string errorMessage)
	{
		Debug.Log ("LoginFailed: error = " + error.ToString() + ", errorMessage = " + errorMessage);
		m_IsLoggedIn = false;
	}
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserStruct"/> struct.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <remarks>Documented by Dev05, 2009-03-04</remarks>
 private UserStruct(string username)
 {
     UserName = username;
     Password = string.Empty;
     Identifier = string.Empty;
     AuthenticationType = null;
     CloseOpenSessions = false;
     LastLoginError = LoginError.NoError;
 }