public EmailSpecs()
 {
     _emails = new Emails();
 }
Exemple #2
0
        /// <summary>
        /// Method used to Register a new user with the Application
        /// </summary>
        /// <param name="email">Email, this will act as the user's User Name</param>
        /// <param name="password">Password</param>
        /// <param name="confirmPassword">Password Confirmation</param>
        /// <returns>A Dynamic Results object containing status and any messages</returns>
        public dynamic Register(string email, string password, string confirmPassword, bool requirePasswordChange = false, bool sendEmail = false)
        {
            dynamic result = new ExpandoObject();
            result.Success = false;

            if (ValidationEmailFormat(email) && PasswordComplexityCheck(password) && password.Equals(confirmPassword))
            {
                try
                {
                    result.UserId = this.Insert(new { Email = email, HashedPassword = Hash(password), RequirePasswordChange = requirePasswordChange });
                    result.Success = true;
                    result.Authenticated = true;
                    result.Message = "Registration Successful!";

                    if (sendEmail)
                    {
                        var emailResult = new Emails().SendThirdPartySignup(email, password);
                        if (emailResult.Success == false)
                        {
                            // Do something here to roll it back
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.Message = "This user email address already exists";
                }
            }
            else
            {
                result.Message = "Either the Email was invalid, the Password wasn't long enough or the Password and the Confirmation didn't match";
            }

            return result;
        }