Beispiel #1
0
        public Result CreateAccount(UserAccountCreationInfo userInfo, out User user)
        {
            // Validate dto
            ValidationHelper.ValidateModel(userInfo);

            // Create user object
            user = Mapper.Map <User>(userInfo);
            user.PasswordHash  = PasswordHashHelper.CreateHash(userInfo.Password);
            user.LastLoginDate = DateTime.Now;

            // Validate user
            ValidationHelper.ValidateModel(user);

            // Other validations
            string email = user.Email;

            if (dataAccessor.Users.Any(other => email == other.Email))
            {
                throw new ValidationException(MsgAccountWithEmailExists);
            }

            // Do save
            dataAccessor.Create(user);
            dataAccessor.SaveChanges();

            return(Login(new LoginInfo {
                Email = userInfo.Email, Password = userInfo.Password
            }));
        }
Beispiel #2
0
        public Result CreateAccount(UserAccountCreationInfo userInfo)
        {
            User ignored;

            return(CreateAccount(userInfo, out ignored));
        }
Beispiel #3
0
 public Result CreateAccount(UserAccountCreationInfo userInfo)
 {
     return(authenticationService.CreateAccount(userInfo));
 }