mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 02:22:49 -05:00
verify email apis
This commit is contained in:
@ -80,7 +80,7 @@ namespace Bit.Core.Identity
|
||||
|
||||
public Task<bool> GetEmailConfirmedAsync(User user, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return Task.FromResult(true); // all emails are confirmed
|
||||
return Task.FromResult(user.EmailVerified);
|
||||
}
|
||||
|
||||
public Task<string> GetNormalizedEmailAsync(User user, CancellationToken cancellationToken = default(CancellationToken))
|
||||
@ -121,7 +121,7 @@ namespace Bit.Core.Identity
|
||||
|
||||
public Task SetEmailConfirmedAsync(User user, bool confirmed, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
// do nothing
|
||||
user.EmailVerified = confirmed;
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class VerifyEmailRequestModel
|
||||
{
|
||||
[Required]
|
||||
public string UserId { get; set; }
|
||||
[Required]
|
||||
public string Token { get; set; }
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace Bit.Core.Services
|
||||
var message = CreateDefaultMessage("Verify Your Email", email);
|
||||
var model = new VerifyEmailModel
|
||||
{
|
||||
Token = token,
|
||||
Token = WebUtility.UrlEncode(token),
|
||||
UserId = userId,
|
||||
WebVaultUrl = _globalSettings.BaseVaultUri,
|
||||
SiteName = _globalSettings.SiteName
|
||||
|
@ -294,7 +294,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
if(user.EmailVerified)
|
||||
{
|
||||
throw new BadRequestException("Email already verifed.");
|
||||
throw new BadRequestException("Email already verified.");
|
||||
}
|
||||
|
||||
var token = await base.GenerateEmailConfirmationTokenAsync(user);
|
||||
|
@ -103,6 +103,7 @@ namespace Bit.Core.Utilities
|
||||
identityBuilder
|
||||
.AddUserStore<UserStore>()
|
||||
.AddRoleStore<RoleStore>()
|
||||
.AddTokenProvider<DataProtectorTokenProvider<User>>(TokenOptions.DefaultProvider)
|
||||
.AddTokenProvider<AuthenticatorTokenProvider>(TwoFactorProviderType.Authenticator.ToString())
|
||||
.AddTokenProvider<YubicoOtpTokenProvider>(TwoFactorProviderType.YubiKey.ToString())
|
||||
.AddTokenProvider<DuoWebTokenProvider>(TwoFactorProviderType.Duo.ToString())
|
||||
|
Reference in New Issue
Block a user