-
-
-
-
+
diff --git a/strr-web/middleware/setupAuth.global.ts b/strr-web/middleware/setupAuth.global.ts
new file mode 100644
index 00000000..62682461
--- /dev/null
+++ b/strr-web/middleware/setupAuth.global.ts
@@ -0,0 +1,42 @@
+export default defineNuxtRouteMiddleware(async (to) => {
+ // setup auth
+ if ((!to.query.error) && !process.env.VITEST_WORKER_ID) {
+ // keycloak redirects with the error param when not logged in (nuxt/keycloak issue)
+ // - removing ^ condition will cause an infinite loop of keycloak redirects when not authenticated
+ const { kcURL, kcRealm, kcClient } = useRuntimeConfig().public
+ await useBcrosAuth().setupAuth(
+ { url: kcURL, realm: kcRealm, clientId: kcClient },
+ to.params.currentAccountId as string || to.query.currentAccountId as string
+ )
+
+ // if (process.client && sessionStorage?.getItem('FAKE_LOGIN')) {
+ // const { kc } = useBcrosKeycloak()
+ // // set test kc values
+ // kc.tokenParsed = {
+ // firstname: 'TestFirst',
+ // lastname: 'TestLast',
+ // name: 'TestFirst TestLast',
+ // username: 'testUsername',
+ // email: 'testEmail@test.com',
+ // sub: 'testSub',
+ // loginSource: 'IDIR',
+ // realm_access: { roles: ['basic'] }
+ // }
+ // kc.authenticated = true
+ // const account = useBcrosAccount()
+ // await account.setUserName()
+ // await account.setAccountInfo()
+ // }
+ }
+ // // initialize ldarkly
+ // useBcrosLaunchdarkly().init()
+ // remove query params in url added by keycloak
+ if (to.query) {
+ const params = new URLSearchParams(to.fullPath.split('?')[1])
+ params.delete('state')
+ params.delete('session_state')
+ params.delete('code')
+ params.delete('error')
+ to.fullPath = to.path + (params.size > 0 ? `?${params}` : '') + to.hash
+ }
+})
diff --git a/strr-web/nuxt.config.ts b/strr-web/nuxt.config.ts
index 8514e8cc..47f4cce8 100644
--- a/strr-web/nuxt.config.ts
+++ b/strr-web/nuxt.config.ts
@@ -59,7 +59,8 @@ export default defineNuxtConfig({
payApiURL: `${process.env.VUE_APP_PAY_API_URL || ''}${process.env.VUE_APP_PAY_API_VERSION || ''}`,
btrApiURL: `${process.env.VUE_APP_BTR_API_URL || ''}${process.env.VUE_APP_BTR_API_VERSION || ''}`,
registryHomeURL: process.env.VUE_APP_REGISTRY_HOME_URL || '',
- appEnv: `${process.env.VUE_APP_POD_NAMESPACE || 'unknown'}`
+ appEnv: `${process.env.VUE_APP_POD_NAMESPACE || 'unknown'}`,
+ version: `0.1.0`,
}
},
css: ['~/./assets/scss/global.scss'],
diff --git a/strr-web/pages/accountselect.vue b/strr-web/pages/accountselect.vue
new file mode 100644
index 00000000..37791d3a
--- /dev/null
+++ b/strr-web/pages/accountselect.vue
@@ -0,0 +1,34 @@
+
+
+
+
+
+ {{ userAccount.label }}-
+ {{ userAccount.accountType }}-
+ {{ userAccount.mailingAddress?.street }}
+ {{ userAccount.mailingAddress?.city }}
+ {{ userAccount.mailingAddress?.region }}
+
+
+
Create an Account
+
+
+ You have no accounts, please Create Account
+
+
+ Please login
+
+
+
+
+
diff --git a/strr-web/pages/index.vue b/strr-web/pages/index.vue
index 04cf6292..71375f7a 100644
--- a/strr-web/pages/index.vue
+++ b/strr-web/pages/index.vue
@@ -1,6 +1,7 @@
-
-
Page content
- Login
-
+ Welcome!
+
+
diff --git a/strr-web/stores/account.ts b/strr-web/stores/account.ts
index a5d7e0f8..b735919a 100644
--- a/strr-web/stores/account.ts
+++ b/strr-web/stores/account.ts
@@ -69,6 +69,26 @@ export const useBcrosAccount = defineStore('bcros/account', () => {
userLastName.value = user.value?.lastName || ''
}
+ /** Get details for an account (org) */
+ async function getAccountDetails (orgId: string) {
+ const apiURL = useRuntimeConfig().public.authApiURL
+ return await axios.get(`${apiURL}/orgs/${orgId}`)
+ .then((response) => {
+ const data = response?.data
+ if (!data) { throw new Error('Invalid AUTH API response') }
+ return data
+ })
+ .catch((error) => {
+ console.warn('Error fetching user account details.')
+ // TODO: TC - add error handling
+ errors.value.push({
+ statusCode: error?.response?.status || StatusCodes.INTERNAL_SERVER_ERROR,
+ message: error?.response?.data?.message,
+ category: ErrorCategoryE.ACCOUNT_LIST
+ })
+ })
+ }
+
/** Get the user's account list */
async function getUserAccounts (keycloakGuid: string) {
const apiURL = useRuntimeConfig().public.authApiURL
@@ -96,6 +116,7 @@ export const useBcrosAccount = defineStore('bcros/account', () => {
}
if (user.value?.keycloakGuid) {
userAccounts.value = await getUserAccounts(user.value?.keycloakGuid) || []
+
if (userAccounts && userAccounts.value.length > 0) {
currentAccount.value = userAccounts.value[0]
if (currentAccountId) {
@@ -104,6 +125,16 @@ export const useBcrosAccount = defineStore('bcros/account', () => {
}
sessionStorage.setItem(SessionStorageKeyE.CURRENT_ACCOUNT, JSON.stringify(currentAccount.value))
}
+
+ // TODO: TC - loading mail addresses into the store here
+ // Is there a better endpoint to use for this, or should we build our own into API instead
+
+ userAccounts.value.forEach(async (account) => {
+ const details = await getAccountDetails(account.id)
+ if (details) {
+ account.mailingAddress = details.mailingAddress
+ }
+ })
}
}
diff --git a/strr-web/stores/keycloak.ts b/strr-web/stores/keycloak.ts
index 6937a557..20667c27 100644
--- a/strr-web/stores/keycloak.ts
+++ b/strr-web/stores/keycloak.ts
@@ -38,6 +38,8 @@ export const useBcrosKeycloak = defineStore('bcros/keycloak', () => {
sessionStorage.removeItem(SessionStorageKeyE.KEYCLOAK_TOKEN_REFRESH)
sessionStorage.removeItem(SessionStorageKeyE.KEYCLOAK_TOKEN_ID)
sessionStorage.removeItem(SessionStorageKeyE.KEYCLOAK_SYNCED)
+ // TODO: TC - investigate if this fix for "not quite logged out redirect issue"
+ sessionStorage.removeItem(SessionStorageKeyE.CURRENT_ACCOUNT)
}
function syncSessionStorage () {