コード例 #1
0
ファイル: Join.razor.cs プロジェクト: DataJuggler/BlazorChat
 /// <summary>
 /// This method Cancel
 /// </summary>
 public void Cancel()
 {
     // if the value for HasParentIndexPage is true
     if (HasParentIndexPage)
     {
         // Cancel signing up
         ParentIndexPage.SetupScreen(ScreenTypeEnum.Main);
     }
 }
コード例 #2
0
ファイル: Login.razor.cs プロジェクト: DataJuggler/BlazorChat
 /// <summary>
 /// This method Cancel
 /// </summary>
 public void Cancel()
 {
     // if the value for HasParentIndexPage is true
     if (HasParentIndexPage)
     {
         // Restore back to main screen
         ParentIndexPage.SetupScreen(ScreenTypeEnum.Main);
     }
 }
コード例 #3
0
ファイル: Join.razor.cs プロジェクト: DataJuggler/BlazorChat
        /// <summary>
        /// This method Process New User Sign Up
        /// </summary>
        public async void ProcessNewUserSignUp(object userObject)
        {
            // get the user
            User user = userObject as User;

            // if the user exists
            if (NullHelper.Exists(user))
            {
                // Get the KeyCode
                string keyCode = EnvironmentVariableHelper.GetEnvironmentVariableValue(Connection.Name);

                // If the keyCode string exists
                if (TextHelper.Exists(keyCode))
                {
                    // Set the PasswordHash, this takes the longest time
                    user.PasswordHash = CryptographyHelper.GeneratePasswordHash(Password, keyCode, 3);

                    // if the password hash was created
                    if (TextHelper.Exists(user.PasswordHash))
                    {
                        // save the user
                        bool saved = await UserService.SaveUser(ref user);

                        // if saved
                        if ((saved) && (HasParentIndexPage))
                        {
                            // Force the user to login, see if they entered real data
                            ParentIndexPage.SetupScreen(ScreenTypeEnum.Login);
                        }
                        else
                        {
                            // Show a messagge
                            ValidationMessage = "Oops, something went wrong. Please try again with a different password.";
                        }
                    }
                    else
                    {
                        // Show a messagge
                        ValidationMessage = "Oops, something went wrong. Please try again with a different password.";
                    }
                }
            }
        }
コード例 #4
0
ファイル: Login.razor.cs プロジェクト: DataJuggler/BlazorChat
        /// <summary>
        /// This method Handle Remember Password
        /// </summary>
        public async Task <bool> HandleRememberPassword()
        {
            // initial value
            bool saved = false;

            // if the value for HasParentIndexPage is true
            if (HasParentIndexPage)
            {
                // if remember login details is true
                if ((RememberLogin) && (HasLoggedInUser))
                {
                    // Store the local store items
                    await ParentIndexPage.StoreLocalStoreItems(LoggedInUser.EmailAddress, LoggedInUser.PasswordHash);
                }
                else
                {
                    // Remove any locally stored items
                    await ParentIndexPage.RemovedLocalStoreItems();
                }
            }

            // return value
            return(saved);
        }
コード例 #5
0
ファイル: Login.razor.cs プロジェクト: DataJuggler/BlazorChat
        /// <summary>
        /// This method Process New User Sign Up
        /// </summary>
        public async void ProcessVerifyPassword(object userObject)
        {
            try
            {
                // cast the object as a signUpModel object
                User user = userObject as User;

                // If the user object exists
                if (NullHelper.Exists(user))
                {
                    // Get the KeyCode
                    string keyCode = EnvironmentVariableHelper.GetEnvironmentVariableValue(Connection.Name);

                    // verify the user is logged in
                    bool verified = CryptographyHelper.VerifyHash(password, keyCode, user.PasswordHash);

                    // if not verified
                    if (!verified)
                    {
                        // Set the message
                        ValidationMessage = "The credentials entered were either not found or invalid.";

                        // hide the progress
                        ShowProgress = false;
                    }
                    else
                    {
                        // Set the LoggedInUser on this page
                        LoggedInUser = user;

                        // Set the LoggedInUser
                        ParentIndexPage.LoggedInUser = user;

                        // if the value for RememberLogin is true
                        if (RememberLogin)
                        {
                            // Save the login details in local protected storage
                            await HandleRememberPassword();
                        }

                        // Update the login information for this user
                        user.LastLoginDate = DateTime.Now;

                        // add to their total logins
                        user.TotalLogins++;

                        // Save the user
                        bool saved = await UserService.SaveUser(ref user);

                        // Set the Logged In User
                        ParentIndexPage.LoggedInUser = user;

                        // Return to the Main Screen, and now you can enter chat
                        ParentIndexPage.SetupScreen(ScreenTypeEnum.Main);
                    }
                }
                else
                {
                    // Set the message
                    ValidationMessage = "The credentials entered were either not found or invalid.";

                    // hide the progress
                    ShowProgress = false;
                }
            }
            catch (Exception error)
            {
                // for debugging only for now
                DebugHelper.WriteDebugError("ProcessVerifyPassword", "Login.razor.cs", error);
            }
        }