Exemple #1
0
        public static async Task <ConfirmationEmailResponseDto> ConfirmEmail(this UserManager <User> userManager, IUserStore <User> userStore,
                                                                             User user)
        {
            var confirmationEmailResponse = new ConfirmationEmailResponseDto();

            if (user == null)
            {
                return(ConfirmationEmailUserNotFound(confirmationEmailResponse));
            }
            if (user.EmailConfirmed)
            {
                return(ConfirmationEmailAlreadyConfirmed(confirmationEmailResponse));
            }
            if (user.EmailConfirmationTokenExpirationTime < DateTime.UtcNow)
            {
                return(ConfirmationEmailTokenExpired(confirmationEmailResponse));
            }
            user.EmailConfirmed = true;
            var result = await userStore.UpdateAsync(user, CancellationToken.None);

            confirmationEmailResponse.Invalid = confirmationEmailResponse.Succedeed = result.Succeeded;
            return(confirmationEmailResponse);
        }
Exemple #2
0
 private static ConfirmationEmailResponseDto ConfirmationEmailUserNotFound(
     ConfirmationEmailResponseDto confirmationEmailResponse)
 {
     confirmationEmailResponse.Invalid = true;
     return(confirmationEmailResponse);
 }
Exemple #3
0
 private static ConfirmationEmailResponseDto ConfirmationEmailAlreadyConfirmed(
     ConfirmationEmailResponseDto confirmationEmailResponse)
 {
     confirmationEmailResponse.AlreadyConfirmed = true;
     return(confirmationEmailResponse);
 }
Exemple #4
0
 private static ConfirmationEmailResponseDto ConfirmationEmailTokenExpired(
     ConfirmationEmailResponseDto confirmationEmailResponse)
 {
     confirmationEmailResponse.Expired = true;
     return(confirmationEmailResponse);
 }