Example #1
0
        public ActionResult Register()
        {
            var name     = Request.Form["username"];
            var email    = Request.Form["email"];
            var password = _cyberSecurity.EncryptPassword(Request.Form["password"]);

            try
            {
                _sqlUsersService.AddUser(name, email, password);
            }
            catch (Npgsql.PostgresException)
            {
                return(Json("You already registerd. Email address taken!"));
            }

            return(Json("Success!"));
        }
Example #2
0
        public IActionResult NewUser([FromForm] string Name, [FromForm] string Password)
        {
            var user = new UserModel();

            user.Password = _cyberSecurity.EncryptPassword(Password);
            user.Name     = Name;

            try
            {
                _datahandler.AddUser(user);
            }
            catch (Npgsql.PostgresException)
            {
                return(Redirect("InvalidUsername"));
            }

            return(Redirect("Login"));
        }