Пример #1
0
        public User CreateUser(string username, string password)
        {
            var user = new User();

            user.Username     = username;
            user.PasswordSalt = crypto.CreateSalt();
            user.PasswordHash = crypto.GetPasswordHash(password, user.PasswordSalt);
            return(user);
        }
Пример #2
0
        public Account Register(RegisterRepresentation newRegistration)
        {
            newRegistration.Password = _cryptographer.GetPasswordHash(
                newRegistration.Password,
                _cryptographer.CreateSalt());
            var newAccount = _registrationMapper.Map(newRegistration);

            if (newAccount.Provider == "OAuth")
            {
                newAccount.ConfirmEmail(DateTime.Now);
            }

            return(newAccount);
        }
Пример #3
0
        public object Execute(UpdateUserCommandMessage commandMessage)
        {
            var user = _repository.GetById(commandMessage.Id) ?? new User();

            user.Name         = commandMessage.Name;
            user.EmailAddress = commandMessage.EmailAddress;
            user.PasswordSalt = _cryptographer.CreateSalt();
            user.PasswordHash = _cryptographer.GetPasswordHash(commandMessage.Password,
                                                               user.PasswordSalt);
            user.Username = commandMessage.Username;

            _repository.Save(user);

            return(user);           // new ReturnValue { Type = typeof(User), Value = user };
        }