Exemplo n.º 1
0
 public void Signup(string username, string password, string passwordRepeat, string firstName, string lastName, SignUpPage signup)
 {
     if (password == passwordRepeat)
     {
         password = Sha256(password, signup);
         string hash = BCrypt.HashPassword(password, BCrypt.GenerateSalt());
         client = new WebClient();
         string response = client.DownloadString(new Uri("https://meetup-app.000webhostapp.com/signup.php?username="******"&password="******"&firstname=" + firstName + "&lastname=" + lastName));
         if (response == "success")
         {
             signup.DisplayAlert("Success", "Account created.", "Log-in");
             signup.Navigation.PopToRootAsync();
         }
         else
         {
             signup.DisplayAlert("Error", response, "Try again");
         }
     }
     else
     {
         signup.DisplayAlert("Error", "Passwords do not match.", "Try again");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Invoked when the Sign Up button is clicked.
        /// </summary>
        /// <param name="obj">The Object</param>
        private async void SignUpClicked(object obj)
        {
            var signUpRequest = new SignUpRequest
            {
                Email           = Email,
                Password        = Password,
                ConfirmPassword = ConfirmPassword,
                Name            = Name
            };
            var result = await authorizationService.SignUp(signUpRequest);

            if (result.IsSuccess)
            {
                App.IsUserLoggedId           = true;
                App.Token                    = result.Token;
                App.UserId                   = result.UserId;
                Application.Current.MainPage = new NavigationPage(new BottomNavigationPage());
            }
            else
            {
                await page.DisplayAlert("Error", result.ErrorMessage, "Ok");
            }
        }
Exemplo n.º 3
0
        public async void SignUp(object obj)
        {
            IsBusy         = true;
            LoadingMessage = "Creating Account...";

            Regex regex = new Regex("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{6,20}$");

            if (
                string.IsNullOrEmpty(name) ||
                string.IsNullOrEmpty(email) ||
                string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(confirmPassword) ||
                string.IsNullOrEmpty(gender) ||
                birthday == null
                )
            {
                await signUpPage.DisplayAlert("Error", "Fields with * cannot be empty", "Ok");
            }
            else if (!regex.Match(password).Success)
            {
                await signUpPage.DisplayAlert("Error",
                                              "Passwords should be 6 to 20 chars long and should be a combination of numbers, small and capital letters",
                                              "Ok");
            }
            else if (!password.Equals(confirmPassword))
            {
                await signUpPage.DisplayAlert("Error", "Passwords doesn't match", "Ok");
            }
            else
            {
                //Check if email id already exists
                if (await ServiceLocator.AzureService.GetUserByEmail(email) != null)
                {
                    IsBusy = false;
                    await signUpPage.DisplayAlert("Sorry", "Email id already exists!", "Please sign in or enter different email id");

                    return;
                }

                //Create BAMPppUser Object
                BAMAppUser user = CreateUserInstance();
                user.Password = Password;
                await ServiceLocator.AzureService.Add(user);

                //if inserted successfully navigate
                BAMAppUser savedUser = await ServiceLocator.AzureService.GetUserByEmail(user.Email);

                if (savedUser != null)
                {
                    //save userID and user info to local settings
                    Settings.UserId = savedUser.Id;
                    Settings.Avatar = user.Avatar;
                    Settings.Name   = user.Name;

                    //remove  sign up page from navigation stack
                    signUpPage.Navigation.InsertPageBefore(new HomePage(), signUpPage.Navigation.NavigationStack.First());
                    await signUpPage.Navigation.PopToRootAsync();
                }
            }

            IsBusy = false;
        }