Exemple #1
0
        public static string ChipperPassword(string pass)
        {
            string keySalt = new ConfigurationManager().GetSettingsValue("keySalt");
            var    hash    = HashPwd.GetHashPassword(pass, keySalt);

            return(hash);
        }
        private async void Authenticate_Click(object sender, RoutedEventArgs e)
        {
            this.Loading_Show(true);
            string usuario = ((TextBox)FindChildControl <TextBox>(LoginForm, "Usuario")).Text;

            string password = HashPwd.GetHash(((PasswordBox)FindChildControl <PasswordBox>(LoginForm, "Password")).Password);

            bool remember = (bool)((AppBarToggleButton)FindChildControl <AppBarToggleButton>(LoginForm, "Remember")).IsChecked;

            if (usuario.Equals("") || password.Equals(""))
            {
                Alert.CreateAlert("Ingrese los datos correctos.", "Sistema CEM - Error en credenciales");
            }
            else
            {
                Object response = false;

                try
                {
                    response = await this.AuthService.aunthenticate(usuario, password);

                    if (response.Equals(false))
                    {
                        Alert.CreateAlert("Ingrese los datos correctos.", "Sistema CEM - Error en credenciales");
                    }
                    else
                    {
                        this.SessionManager.Add("usuario", response);
                        this.SessionManager.Add("remember", remember.ToString());
                        this.ShowSections(true);
                    }
                }
                catch (Exception)
                {
                    Alert.CreateAlert("Ocurrió un error al intentar conectar. Compruebe su conexión e intente más tarde.", "Sistema CEM - Error de conexión");
                }
            }

            this.Loading_Show(false);
        }