Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18115 get keycload token from rootState #742

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-request",
"version": "5.3.3",
"version": "5.3.4",
"private": true,
"appName": "Name Request UI",
"sbcName": "SBC Common Components",
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/current-account-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** The current account interface.
* A logged-in user can select between multiple accounts */
export interface CurrentAccountIF {
accountStatus: string
accountType: string
additionalLabel: string
id: number
label: string
productSettings: string
type: string
urlorigin: string
urlpath: string
}
11 changes: 11 additions & 0 deletions src/interfaces/current-user-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** The Current User (aka: Keycloak) interface. */
export interface CurrentUserIF {
email: string
firstName: string
fullName: string
keycloakGuid: string
lastName: string
loginSource: string
roles: Array<string>
userName: string
}
3 changes: 3 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export * from './models'
export * from './name-check-interfaces'
export * from './dialog-options'
export * from './refund-params-interface'
export * from './current-user-interface'
export * from './current-account-interface'
export * from './root-state-interface'

// external interfaces
export type {
Expand Down
14 changes: 14 additions & 0 deletions src/interfaces/root-state-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CurrentUserIF, CurrentAccountIF } from '@/interfaces'

/** The ROOT state model interface. */
export interface RootStateIF {
account: {
currentUser: CurrentUserIF,
currentAccount: CurrentAccountIF
},
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
auth: {
token: string,
idToken: string,
refreshToken: string
}
}
7 changes: 4 additions & 3 deletions src/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
StaffPaymentIF,
StateIF,
StatsI,
SubmissionTypeT
SubmissionTypeT,
RootStateIF
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
} from '@/interfaces'
import {
CompanyTypes,
Expand Down Expand Up @@ -67,8 +68,8 @@ export const isMobile = (state: StateIF): boolean => {
}

/** True if user is authenticated, else False. */
export const isAuthenticated = (): boolean => {
return Boolean(sessionStorage.getItem(SessionStorageKeys.KeyCloakToken))
export const isAuthenticated = (rootState: RootStateIF): boolean => {
return Boolean(rootState.auth && rootState.auth.token)
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
}

export const getCurrentJsDate = (state: StateIF): Date => {
Expand Down
Loading