User expired property always true
See original GitHub issueI recently ran into an issue where the user expired
property was always true even just after receiving a new token from the identity server.
The current User.test.ts
passes but if it is updated to use jest mock timers, it fails.
Example:
import { User } from "./User";
describe("User", () => {
beforeEach(() => {
jest.useFakeTimers(); // changed from jest.spyOn
});
afterEach(() => {
jest.restoreAllMocks();
});
describe("expired", () => {
it("should calculate how much time left", () => {
const subject = new User({ expires_at: 100 } as never);
expect(subject.expired).toEqual(false);
// act
jest.advanceTimersByTime(100); // changed from "now += 100"
// assert
expect(subject.expired).toEqual(true);
});
});
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
If user password expired , any AD attributes change ? - TechNet
First, the pwdLastSet attribute is not changed to zero when a user password expires. The value remains unchanged, corresponding to the datetime ...
Read more >IsAuthenticated stays true after expiry - Stack Overflow
When the user is authenticated, a ticket is issued. To save on DB queries, that ticket is revalidated on an interval (20 minutes...
Read more >Account Expiration
If a user object in Active Directory has never had an expiration date, the accountExpires attribute is set to a huge number. The...
Read more >Expired AD accounts remains active in Azure AD - blksthl
The 'Enabled' property of a user account is one of the properties that are always synced to Azure AD. This is on an...
Read more >useSession({ required: true }), which always returns a non-null ...
A living session could be a requirement for specific pages. If it doesn't exist, then the user should be redirected to the sign...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pamapa that code removed in the diff wasn’t setting
expires_in
, it was a redundant assignment ensuring thatexpires_in
is stored as a number as opposed to a string. I removed it since we already cast it as a number in the setter.The actual assignment occurs in the
Object.assign
when the code is exchanged: https://github.com/authts/oidc-client-ts/blob/8bf2b68629d9b48d79f28c8cfc88db2d5000d5b6/src/ResponseValidator.ts#L220-L228The other one for refresh tokens is here: https://github.com/authts/oidc-client-ts/blob/8bf2b68629d9b48d79f28c8cfc88db2d5000d5b6/src/OidcClient.ts#L171-L177
As changing the time (in unit-test) after the
expires_at
was calculated has no impact on theexpires_at
i will soon close this issue, unless you report more info…