mirror of
https://github.com/bitwarden/server
synced 2025-12-17 08:43:27 +00:00
verify email apis and emails
This commit is contained in:
@@ -15,6 +15,7 @@ using Bit.Core.Models.Business;
|
||||
using U2fLib = U2F.Core.Crypto.U2F;
|
||||
using U2F.Core.Models;
|
||||
using U2F.Core.Utils;
|
||||
using Bit.Core.Exceptions;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
@@ -289,6 +290,17 @@ namespace Bit.Core.Services
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task SendEmailVerificationAsync(User user)
|
||||
{
|
||||
if(user.EmailVerified)
|
||||
{
|
||||
throw new BadRequestException("Email already verifed.");
|
||||
}
|
||||
|
||||
var token = await base.GenerateEmailConfirmationTokenAsync(user);
|
||||
await _mailService.SendVerifyEmailEmailAsync(user.Email, user.Id, token);
|
||||
}
|
||||
|
||||
public async Task InitiateEmailChangeAsync(User user, string newEmail)
|
||||
{
|
||||
var existingUser = await _userRepository.GetByEmailAsync(newEmail);
|
||||
|
||||
Reference in New Issue
Block a user