protected void btnRegister_Click(object sender, EventArgs e)
        {
            // read values from the text fields
            string username    = txtUsername.Text.Trim();
            string password    = Encryptor.EncryptText(txtPassword.Text.Trim());
            string passwordCon = Encryptor.EncryptText(txtConfirmPassword.Text.Trim());

            if (!password.Equals(passwordCon))
            {
                lblMessage.Text      = "Passwords do not match. Please try again.";
                lblMessage.ForeColor = System.Drawing.Color.Red;
                return;
            }

            AuthenticationLogic al = new AuthenticationLogic();

            User user = al.GetUserByName(username);

            if (user != null)
            {
                lblMessage.Text      = "Username is taken. Please try again.";
                lblMessage.ForeColor = System.Drawing.Color.Red;
                return;
            }

            if (al.CreateUser(new User(0, username, password, "Member", "")) == 1)
            {
                lblMessage.Text      = "Registration Complete!";
                lblMessage.ForeColor = System.Drawing.Color.Green;
                return;
            }
        }
Ejemplo n.º 2
0
        public void CreateUser(string tenantName, string username, string password, string email)
        {
            if (string.IsNullOrEmpty(tenantName))
            {
                throw new ArgumentNullException("tenantName");
            }
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException("username");
            }
            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentNullException("email");
            }

            AuthenticationLogic.CreateUser(tenantName, username, password, email);
        }