public async Task <string> Register(RegisterViewModel model) { await _authValidationService.ValidateRegisterViewModel(model); var newUser = new OmdleUser { UserName = model.UserName, FirstName = model.FirstName, LastName = model.LastName, Email = model.Email }; var result = await _userManager.CreateAsync(newUser, model.Password); if (!result.Succeeded) { throw new RegistrationFailedException( $"An error occured while registering user: {result.Errors.Select(e => e.Description).Join(", ")}"); } await _userManager.AddToRoleAsync(newUser, "Student"); await _signInManager.SignInAsync(newUser, false); var token = await GetToken(newUser); return(token); }
public async Task <string> Register(RegisterRequestDto model) { _authValidationService.ValidateRegisterViewModel(model); var newUser = new WorkshopUser { UserName = model.UserName, Email = model.Email //FirstName = model.FirstName, //LastName = model.LastName }; var result = await _userManager.CreateAsync(newUser, model.Password); await _userManager.AddToRoleAsync(newUser, WorkshopRoleNames.Client); if (!result.Succeeded) { throw new RegisterFailedException( $"An error occured while registering user: {string.Join(",", result.Errors.Select(x => x.Description))}"); } await _signInManager.SignInAsync(newUser, false); return(await GetToken(newUser)); }
public async Task <string> Register(RegisterViewModel model) { _authValidationService.ValidateRegisterViewModel(model); var newUser = new AllergoUser { UserName = model.UserName, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName }; var result = await _userManager.CreateAsync(newUser, model.Password); await _userManager.AddToRoleAsync(newUser, AllergoRoleNames.Patient); if (!result.Succeeded) { throw new BadRequestException( $"An error occured while registering user: {result.Errors.Select(x => x.Description).Join()}"); } await _signInManager.SignInAsync(newUser, false); return(await GetToken(newUser)); }
public async Task <string> Register(RegisterViewModel model) { await _authValidationService.ValidateRegisterViewModel(model); var newUser = new ElanUser { UserName = model.UserName, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PasswordHintQuestion = model.Question, PasswordHintAnswer = model.Answer, Gender = model.Gender }; var result = await _userManager.CreateAsync(newUser, model.Password); if (!result.Succeeded) { throw new RegistrationFailedException( $"An error occured while registering user: {result.Errors.Select(e => e.Description).Join(", ")}"); } await _userSettings.AddSettings(newUser); await _signInManager.SignInAsync(newUser, false); return(GetToken(newUser)); }