Beispiel #1
0
        public IActionResult Register(User u)
        {
            User userInDb = context.GetUserByEmail(u.Email);

            if (userInDb != null)
            {
                ModelState.AddModelError("Email", "Email already in use!");
            }
            if (ModelState.IsValid)
            {
                u.Password = RegisterHasher.HashPassword(u, u.Password);
                int UserId = context.Create(u);
                HttpContext.Session.SetInt32("UserId", UserId);
                return(Redirect("/events"));
            }
            return(View("Index"));
        }