private async void btn_login_clicked(object sender, EventArgs e)
        {
            act_Indicator.IsVisible = true;

            await Task.Run(async() =>
            {
                await Task.Delay(500);
            });

            try

            {
                string email          = entry_email.Text;
                string value          = Database.GetSaltedPW(email);
                string SaltedPassword = value.Replace(' ', '=');
                SaltedPassword = value.Replace('+', '=');
                string password = HashAndSalt.HashString(String.Format("{0}{1}", entry_password.Text, SaltedPassword));
                int    userID   = Database.CheckUser(email, password);

                if (userID > 0)
                {
                    Application.Current.Properties["IsLoggedIn"] = Boolean.TrueString;
                    Application.Current.Properties["userID"]     = userID;

                    //Set UserID
                    SpecificUser.UserID = userID;

                    //Set Initial Database-Requests
                    RatedBeer.highscores                           = Database.Highscore();
                    RatedBeer.criterias                            = Database.ShowCriteria();
                    Objects.DashBoard.friendsRating                = Database.showFriendLast(SpecificUser.UserID);
                    BetterBeer.Objects.DashBoard.count             = Database.countRatings(SpecificUser.UserID);
                    BetterBeer.Objects.DashBoard.friendRatingCount = Database.countFriendRatings(SpecificUser.UserID);
                    BetterBeer.Objects.DashBoard.friend            = BetterBeer.Objects.DashBoard.getFriends();
                    BetterBeer.Objects.DashBoard.friendsRatingList = BetterBeer.Objects.DashBoard.getFriendsRating();
                    Friend.friends          = Database.GetFriends();
                    act_Indicator.IsVisible = false;

                    //Push DashBoard
                    await Navigation.PushAsync(new DashBoard());
                }
                else
                {
                    act_Indicator.IsVisible = false;
                    await DisplayAlert("Fehlgeschlagen", "Anmelden fehlgeschlagen", "Mist");

                    entry_email.Text    = "";
                    entry_password.Text = "";
                }
            }
            catch (Exception)
            {
                act_Indicator.IsVisible = false;
                await DisplayAlert("Fehler", "Ups, hier ist etwas schiefgegangen.", "Ok");

                entry_password.Text = "";
            }
        }
示例#2
0
        private async void btn_create_clicked(object sender, EventArgs e)
        {
            try
            {
                string uName          = entry_UserName.Text;
                string email          = entry_eMail.Text;
                string value          = HashAndSalt.CreateSalt();
                string SaltedPassword = value.Replace(' ', '=');
                SaltedPassword = value.Replace('+', '=');
                string password  = HashAndSalt.HashString(String.Format("{0}{1}", entry_password.Text, SaltedPassword));
                string password2 = HashAndSalt.HashString(String.Format("{0}{1}", entry_password2.Text, SaltedPassword));


                if (uName == null || password == null)
                {
                    await DisplayAlert("Achtung", "Benutzername oder Passwort fehlen", "Ok");
                }
                else if (password.Equals(password2) == false)
                {
                    await DisplayAlert("Achtung", "Passwörter stimmer nicht überein", "Ok");
                }
                else
                {
                    if (Database.NewUser(uName, email, password, SaltedPassword))
                    {
                        await DisplayAlert("Super", "Dein Account wurde erfolgreich angelegt", "Ok");

                        App.Current.MainPage = new NavigationPage(new MainPage());
                    }
                    else
                    {
                        await DisplayAlert("Fehlgeschlagen", "Dein Account konnte nicht angelegt werden. \nBenutzername oder Email schon vorhanden", "Mist");
                    }
                }
            }
            catch (Exception)
            {
                await DisplayAlert("Fehler", "Ups, hier ist etwas schiefgegangen", "Ok");
            }
        }