Пример #1
0
        public async Task <bool> UpdateUserPassword(UpdateUserPasswordRequestModel request)
        {
            var newSalt           = GenerateSalt();
            var newHashedPassword = HashPassword(request.NewPassword, newSalt);
            var result            = await _userRepo.UpdateUserPassword(request.UserId, newSalt, newHashedPassword);

            return(result);
        }
Пример #2
0
        public async Task <IActionResult> MyProfile(UpdateProfileVM model)
        {
            if (string.IsNullOrWhiteSpace(model.FirstName) || string.IsNullOrWhiteSpace(model.LastName) || string.IsNullOrWhiteSpace(model.Email))
            {
                return(View(model));
            }

            var user = await _userDataService.GetUser(User.UserId());

            var request = new UpdateUserRequestModel()
            {
                UserId      = User.UserId(),
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                Email       = model.Email,
                PhoneNumber = model.PhoneNumber
            };

            user = await _userDataService.UpdateUser(request);

            if (model.NewPassword != null)
            {
                var updatePasswordRequest = new UpdateUserPasswordRequestModel()
                {
                    UserId      = user.Id,
                    NewPassword = model.NewPassword
                };
                var success = await _userDataService.UpdateUserPassword(updatePasswordRequest);
            }

            await HttpContext.Authentication.SignOutAsync();

            await LogUserIn(user, false);

            return(View());
        }