diff --git a/src/components/util/util.js b/src/components/util/util.js index 67c8a85ad..fc81052e4 100644 --- a/src/components/util/util.js +++ b/src/components/util/util.js @@ -149,5 +149,6 @@ export function getValue(value) { // Given a user record, test whether the user is active. Checking the `active` property ought to // be sufficient, but test the expiration date as well just to be sure. export function checkUserActive(user) { + if (user.expirationDate == null || user.expirationDate == undefined) return user.active; return user.active && (new Date(user.expirationDate) >= new Date()); } diff --git a/src/components/util/util.test.js b/src/components/util/util.test.js index 99bb38da7..f7166aff7 100644 --- a/src/components/util/util.test.js +++ b/src/components/util/util.test.js @@ -29,4 +29,14 @@ describe('checkUserActive', () => { expect(checkUserActive(user)).toBe(false); }); + + it('returns true for active users without an expiration date', () => { + const expDate = new Date(); + const user = { + active: true, + expirationDate: undefined, + }; + + expect(checkUserActive(user)).toBe(true); + }); });