-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invert logic of isAuthPreExpiry => isAuthExpired
- Loading branch information
1 parent
335837a
commit 01cf3ac
Showing
4 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { AuthConfig } from "../app/components/providers/types/AuthConfigTypes"; | ||
import { UserState } from "../app/components/providers/types/UserTypes"; | ||
|
||
export const authIsPreExpiry = (user: UserState | null): boolean => !!user?.exp && user?.exp * 1000 >= Date.now(); | ||
export const authIsExpired = (user: UserState | null): boolean => | ||
!user?.exp || user?.exp * 1000 < Date.now() | ||
|
||
export const isAuthenticated = (authConfig: AuthConfig | null, user: UserState | null): boolean => | ||
authConfig?.enableAuth === false || !!(authConfig?.enableAuth && user?.token && authIsPreExpiry(user)); | ||
authConfig?.enableAuth === false || !!(authConfig?.enableAuth && user?.token && !authIsExpired(user)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters