Esempio n. 1
0
        public virtual async Task <CheckVerificationCodeResultDto> CheckVerificationCodeAsync(CheckVerificationCodeInputDto input)
        {
            var user = await UserManager.FindByEmailAsync(input.EmailAddress);

            if (user == null)
            {
                throw new UserFriendlyException(L["InvalidEmail"]);
            }
            var cacheItem = await CodeCache.GetAsync(user.Id);

            if (cacheItem == null)
            {
                throw new UserFriendlyException(L["InvalidVerification"]);
            }
            if (cacheItem.Code != input.Code)
            {
                throw new UserFriendlyException(L["InvalidVerification"]);
            }
            await CodeCache.RemoveAsync(user.Id);

            return(new CheckVerificationCodeResultDto(input.EmailAddress, await UserManager.GeneratePasswordResetTokenAsync(user)));
        }