public async Task <Result> ConfirmEmailAsync(string token) { if (string.IsNullOrEmpty(token)) { return(Result.Fail(EC.TokenInvalid, ET.TokenInvalid)); } var model = _jwtTokenHelper.DecodeToken <EmailTokenModel>(token); var codes = await _securityCodesRepository.GetSecurityCodesAsync(model.Email, ProviderType.Email, CodeActionType.ConfirmEmail); if (codes != null && codes.Any()) { _securityCodesRepository.Delete(codes); } else { return(Result.Fail(EC.TokenInvalid, ET.TokenInvalid)); } var user = await _userRepository.GetUserByIdAsync(model.Id); user.EmailConfirmed = true; _userRepository.Put(user); await _unitOfWorks.CommitAsync(); return(Result.OK(user)); }
public async Task RemoveExpiredSecurityCodesAsync() { var codes = await _securityCodeQueryRepository.GetExpiredSecurityCodesAsync(); if (codes.Any()) { _securityCodesRepository.Delete(codes); await _unitOfWorks.CommitAsync(); } }