Esempio n. 1
0
 /// <summary>
 /// Tjekker om passwords er ens og ikke er tomme
 /// </summary>
 /// <returns>bool</returns>
 private bool PasswordChecker()
 {
     if (NewPassword != null && NewPasswordCheck != null && CurrentPassword != null)
     {
         if (NewPassword.Equals(NewPasswordCheck) && CurrentPassword.Equals(MC.CurrentUser.Password))
         {
             MC.CurrentUser.Password = NewPassword;
             return(true);
         }
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> OnPostSaveEditAsync()
        {
            ApplicationUser.EmailAddress = EmailAddress;
            ApplicationUser.FirstName    = FirstName;
            ApplicationUser.LastName     = LastName;

            HashString Hash = new HashString();

            CurrentPassword = Hash.ComputeSha256Hash(CurrentPassword);

            if (!CurrentPassword.Equals(Password))
            {
                CurrentPasswordErrorMessage = "Current password mismatch!!";
                return(Page());
            }

            ApplicationUser.Password = Hash.ComputeSha256Hash(Password);

            _context.Attach(ApplicationUser).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicationUserExists(ApplicationUser.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            EmailAddress = "";
            FirstName    = "";
            LastName     = "";
            Password     = "";

            return(RedirectToPage("/AppUser/Profile", new { Id = ApplicationUser.ID }));
        }
Esempio n. 3
0
 private void UpdateCurrentPasswordAwareTextBlock()
 {
     CurrentPasswordAwareTextBlockVisibility = CurrentPassword.Equals(CurrentUser.Password) ?
                                               Visibility.Collapsed : Visibility.Visible;
 }