public async Task <IActionResult> Register([FromBody] RegistrationRequest registration) { if (!registration.IsValid(DatabaseContext)) { return(BadRequest(registration.Validate(DatabaseContext))); } var user = Map <User>(registration); user.RoleId = DatabaseContext.Roles.First(x => x.RoleName == "User").Id; await _authenticationService.AddUser(user); return(Ok(await _authenticationService.Authenticate(registration.GetEmail(), registration.Password))); }
public async Task <IActionResult> Register([FromBody] RegistrationRequest registration) { if (!registration.IsValid(DatabaseContext)) { return(BadRequest(registration.Validate(DatabaseContext))); } var user = Map <User>(registration); user.EmailVerificationCode = Guid.NewGuid().ToString(); await CreateEmail().SendEmailVerification(user.Email, WebAppUrl + "/verify-email/" + user.EmailVerificationCode); await _authenticationService.AddUser(user); return(Ok(_authenticationService.Authenticate(registration.Email, registration.Password))); }
public ActionResult SignUp(SignUpModel login) { if (ModelState.IsValid) { if (_AuthenticationService.AddUser(login)) { TempData["Success"] = "User Created Successfully !"; return(RedirectToAction("Login", "Authentication")); } else { TempData["Error"] = "Could Not Create User Right Now Please Try Again Later."; return(View()); }; } else { TempData["Error"] = "Error Creating User. Please Check Your Details"; return(View()); } }
public async Task <IActionResult> CreateUser(RegistrationRequest userData) { if (!userData.IsValid(DatabaseContext)) { return(BadRequest(userData.Validate(DatabaseContext))); } await DatabaseContext.Database.BeginTransactionAsync(); var user = Map <User>(userData); user.Password = Guid.NewGuid().ToString(); await _authenticationService.AddUser(user); user.SetNulls(); await user.SetRole(DatabaseContext); await ResetUserPassword(user.Email); DatabaseContext.Database.CommitTransaction(); return(Ok(user)); }
public bool AddUser(UserDataContract user) { return(_service.AddUser(user)); }
public Task Post([FromBody] NewUserDto user) { return(_authenticationService.AddUser(user.Email, user.Password)); }