1
0
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:
Kyle Spearrin
2017-07-01 23:20:19 -04:00
parent c8528384f8
commit 97ad8bd943
12 changed files with 111 additions and 3 deletions

View File

@@ -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);