Beispiel #1
0
        public IActionResult OnPost()
        {
            User newUser = new User(Email, Name, Phone);

            if (!newUser.IsEmailValid())
            {
                EmailError = "Must be a valid email under 256 characters.";
                return(Page());
            }
            else if (!newUser.IsNameValid())
            {
                NameError = "Name must be between 1 and 255 characters.";
                return(Page());
            }
            else if (!newUser.IsPhoneValid())
            {
                PhoneError = "Invalid phone number.";
                return(Page());
            }
            else if (usersDatabase.UserExists(newUser))
            {
                EmailError = "An account with this email already exists.";
                return(Page());
            }

            // Create user
            var  ipAddress = context.HttpContext.Connection.RemoteIpAddress;
            Guid uid       = usersDatabase.CreateUser(newUser, ipAddress);

            return(new RedirectToPageResult("Quote", "User", new { id = uid }));
        }
Beispiel #2
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (permLogin.Text == null || permPassword.Text == null)
            {
                return;
            }

            UsersDatabase.CreateUser(permLogin.Text, permPassword.Text, GetPermision());
            UsersDatabase.Save();
            UsersDatabase.Load();
            UpdateAll();
        }