public async Task RegisterAsync(RegisterRequest model, string origin) { // validate var user = await jwtUserService.GetByEmailAsync(model.Email); if (user != null) { // send already registered error in email to prevent account enumeration emailSenderService.SendAlreadyRegisteredEmail(model.Email, origin); return; } // map model to new account object JwtUserEntity <TKey> account = convertService.RegisterRequestToUser(model); account.Role = Role.User; account.Created = DateTime.UtcNow; account.VerificationToken = tokenService.RandomTokenString(); // hash password account.PasswordHash = passwordService.HashPassword(model.Password); // save account await jwtUserService.AddAsync(account); // send email emailSenderService.SendVerificationEmail(account, origin); }