cornflourblue/aspnet-core-3-jwt-authentication-api

Revoke token does not work.

mjza opened this issue · 1 comments

mjza commented

When I try to revoke the token the request will fail in line 5:

1.        private (RefreshToken, Account) getRefreshToken(string token)
2.       {
3.                var account = _context.Accounts.SingleOrDefault(u => u.RefreshTokens.Any(t => t.Token == token));
4.                if (account == null) throw new AppException("Invalid token");
5.                var refreshToken = account.RefreshTokens.Single(x => x.Token == token);
6.                if (!refreshToken.IsActive) throw new AppException("Invalid token");
7.               return (refreshToken, account);
8.        }

It passes line 3 and 4, so it means it could find the RefreshToken and the related account in line 3, however, later in line 5 I have encountered with the following error:

"message": "Sequence contains no matching element"