Esempio n. 1
0
 private void SetMail()//Pin code
 {
     if (Pin_Entry.Text.Length == 4)
     {
         if (int.TryParse(Pin_Entry.Text, out int num))
         {
             if (int.TryParse(Pin_Repid_Entry.Text, out int nums))
             {
                 if (Pin_Entry.Text != null && Pin_Repid_Entry.Text != null && Pin_Entry.Text == Pin_Repid_Entry.Text)
                 {
                     App.Current.Properties["pin_code"] = Pin_Repid_Entry.Text;
                     CloseAllPopup();
                 }
                 else
                 {
                     animations.Animations_Entry(Pin_Repid_Entry);
                     Pin_Repid_Entry.Text = "";
                     Pin_Entry.Text       = "";
                 }
             }
             else
             {
                 animations.Animations_Entry(Pin_Repid_Entry);
                 Pin_Repid_Entry.Text = "";
             }
         }
         else
         {
             animations.Animations_Entry(Pin_Entry);
             Pin_Entry.Text = "";
         }
     }
     else
     {
         animations.Animations_Entry(Pin_Repid_Entry);
         Pin_Repid_Entry.Text = "";
         Pin_Entry.Text       = "";
     }
 }
Esempio n. 2
0
        public DoubleAuthPage(int ID, string status)
        {
            InitializeComponent();
            switch (status)
            {
            case "ReplisPasswd": Name_Lable.Text = "Изменение пароля"; PinCode_Entry.IsVisible = false; break;

            case "DobleOuth": Name_Lable.Text = "Двухфакторная аутентификация"; PinCode_Entry.IsVisible = true; break;
            }
            if (!connectClass.CheckConnection())
            {
                Connect_ErrorAsync();
            }                                                             //Проверка интернета при загрузке формы
            CrossConnectivity.Current.ConnectivityChanged += (s, e) => { if (!connectClass.CheckConnection())
                                                                         {
                                                                             Connect_ErrorAsync();
                                                                         }
            };

            OctocatImage.Source = ImageSource.FromResource(picture_lincs.LinksResourse() + "replispasswd.png");
            CloseImage.Source   = ImageSource.FromResource(picture_lincs.LinksResourse() + "close_circle_button.png");

            GetMasageButton.Clicked += async(s, a) =>
            {
                switch (status)
                {
                case "ReplisPasswd":
                    await ReplasePasswordAsync(ID);
                    await DisplayAlert("Уведомление", "Новый пароль отправлен на вашу почу", "Ok");

                    CloseAllPopup();
                    break;

                case "DobleOuth":
                    await DoubleAuthAsync(ID);
                    await DisplayAlert("Уведомление", "На вашу почту отправлен Pin-code для подтверждения авторизации", "Ok");

                    break;
                }
            };
            PinCode_Entry.TextChanged += async(s, e) =>
            {
                if (PinCode_Entry.Text.Length == 4)
                {
                    if (passwd == PinCode_Entry.Text)
                    {
                        alive = false;//Остановка таймера
                        CloseAllPopup();
                        await Task.Delay(2000);

                        if (App.Current.Properties.TryGetValue("rol_user", out object rol_user))
                        {
                            switch (rol_user)
                            {
                            case "Admin":
                                await Navigation.PushModalAsync(new AdminPage(), animate);

                                break;

                            case "User":
                                await Navigation.PushModalAsync(new UserPage(), animate);

                                break;
                            }
                        }
                    }
                    else
                    {
                        animations.Animations_Entry(PinCode_Entry);
                        PinCode_Entry.Text = "";
                    }
                }
            };
        }
Esempio n. 3
0
        private async Task Login_Async()//Запрос к серверу на получение данных для авторизации
        {
            try
            {
                if (Login_Entry.Text.Length != 0 && Password_Entry.Text.Length != 0)
                {
                    Dictionary <string, string> tokenDictionary = JWT.GetTokenDictionary(Login_Entry.Text, hash.GetHash(Password_Entry.Text));
                    if (tokenDictionary["access_token"] != "")
                    {
                        App.Current.Properties["token"] = tokenDictionary["access_token"];
                        InfoUser loginUsers = await loginUsersService.Get(App.Current.Properties["token"].ToString());

                        App.Current.Properties["rol_user"] = loginUsers.Rol;
                        if (!double_out)
                        {
                            switch (App.Current.Properties["rol_user"])
                            {
                            case "Admin":
                                await Navigation.PushModalAsync(new AdminPage(), animate);

                                break;

                            case "User":
                                await Navigation.PushModalAsync(new UserPage(), animate);

                                break;
                            }
                        }
                        else
                        {
                            string id = await GetClient();

                            if (id != null)
                            {
                                await PopupNavigation.Instance.PushAsync(new DoubleAuthPage(Convert.ToInt32(id), "DobleOuth"));
                            }
                        }
                    }
                    else
                    {
                        count_click++;
                        animations.Animations_Entry(Password_Entry);
                        Error_Password_RowDefinition.Height = 30;
                        Error_Password_Lable.Text           = "Неверные данные!";
                    }
                }
                if (count_click >= 5)//
                {
                    Login_Button.IsEnabled = false;
                    alive      = true;
                    start_time = DateTime.UtcNow;
                    endTime    = start_time.AddSeconds(30); //AddMinutes(1);
                    Device.StartTimer(TimeSpan.FromSeconds(1), OnTimerTick);
                    double_out          = true;
                    Password_Entry.Text = "";
                }
                else if (count_click >= 2)
                {
                    Error_Password_RowDefinition.Height = 30;
                    Error_Password_Lable.Text           = "Осталось : " + (5 - count_click).ToString() + " попытки";
                }
                else if (count_click >= 0)
                {
                    Error_Password_RowDefinition.Height = 30;
                    Error_Password_Lable.Text           = "Поле Login или пароль незаполно";
                }
            }
            catch { await DisplayAlert("Ошибка", "Поля незаполнены", "Ok"); }
        }