Esempio n. 1
0
        public UserSettingsViewModel(User user)
        {
            User = user;

            NewUserInfo = new UserInfo();
            PasswordInputModel = new PasswordInputModel();

            UserInfoTypes = Enum.GetValues(typeof(UserInfoType))
                                .Cast<UserInfoType>()
                                .ToSelectList(x => x.GetDescription(), x => ((int)x).ToString());
        }
Esempio n. 2
0
        public ActionResult ChangePassword(PasswordInputModel passwordInputModel)
        {
            if (passwordInputModel.Password != passwordInputModel.PasswordRepeat)
                ModelState.AddModelError("passwordInputModel.PasswordRepeat", "Det repiterade lösenordet skiljer sig!");

            if (!ModelState.IsValid)
                return Settings();

            var existingUser = _userService.Get(User.Id);
            existingUser.Password = Encrypter.Encrypt(passwordInputModel.Password);

            _storage.Store(SessionKeys.User, existingUser);

            FlashSuccess("Lösenordet har uppdaterats!");
            return RedirectToAction("Settings");
        }