Exemple #1
0
        public static User CreateUser(string username, string displayName, string password, string emailAddress, string langName, string ip, string reCapResponse)
        {
            ValidateUsername(username);
            ValidateDisplayName(displayName);
            ValidatePassword(password);
            ValidateEmail(emailAddress);
            ValidateLangName(langName);
            ValidateIP(ip);
            ValidateReCapResponse(reCapResponse, ip);

            string passwordSalt       = Hash.GenerateSalt(64);
            string passwordHash       = Hash.HashString(password, passwordSalt, new SHA3.SHA3Managed(512));
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            try
            {
                int    userID       = sqlSP.UserCreateUser(username, displayName, passwordSalt, passwordHash, emailAddress, langName, ip);
                string verifyString = sqlSP.UserGetEmailVerifyString(emailAddress);
                Email.SendVerifyEmail(emailAddress, verifyString, langName);
                User user = new User(userID);
                user.SignInWithPassword(password, ip);
                return(user);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }