예제 #1
0
        //The user press the sign in button
        private async Task SignIn()
        {
            ProfileInfo user = JsonUtil.GetJsonUser();

            //Check if user has an account
            if (user == null)
            {
                SetErrorMessage(2);
                OnPropertyChanged(nameof(ErrorLabelMessage));
            }
            //If the user didn't enter anything in username or password
            else if (String.IsNullOrWhiteSpace(username) || String.IsNullOrWhiteSpace(password))
            {
                //Empty username or password entry
                SetErrorMessage(0);
                OnPropertyChanged(nameof(ErrorLabelMessage));
            }
            else if (!user.username.Equals(username) || !user.password.Equals(Security.Hash(password)))
            {
                //Invalid username or password
                SetErrorMessage(1);
                OnPropertyChanged(nameof(ErrorLabelMessage));
            }
            else
            {
                SystemCache systemCache = JsonUtil.GetJsonSystemCache();
                systemCache.isLoggedIn = SystemCache.LOGGED_IN;
                string json = JsonUtil.Stringify(systemCache);
                JsonUtil.SaveJsonToFile(json, JsonUtil.SYSTEM_CACHE_FILE);

                await MyNavigation.PushModalAsync(new MainPage());
            }
        }
예제 #2
0
        //The user press the forgot password button
        private async Task ForgetPassword()
        {
            ProfileInfo user = JsonUtil.GetJsonUser();

            if (user != null)
            {
                await MyNavigation.PushModalAsync(new ForgetPassword());
            }
        }
        //The user presses the verify
        private async Task ResetPassword()
        {
            //Hash the security answers
            String hashPassword1 = Security.Hash(securityAnswer1);
            String hashPassword2 = Security.Hash(securityAnswer2);

            //Get the security answers from the user profile
            //Compare it to the hash and if it matches, and allow the user to verify
            if (!user.securityAnswer1.Equals(hashPassword1) || !user.securityAnswer2.Equals(hashPassword2))
            {
                //Display the passwords do not match error
                currErrorMessage = wrongPasswordError;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(currErrorMessage));
            }
            else
            {
                //send the user to the reset password page
                await MyNavigation.PushModalAsync(new ResetPassword());
            }
        }
예제 #4
0
 //The user press the sign up button
 public async Task CreateAccount()
 {
     await MyNavigation.PushModalAsync(new CreateAccount());
 }