Skip to content

Commit

Permalink
Merge pull request bcgov#236 from dimak1/feat/account-flow-updates
Browse files Browse the repository at this point in the history
Update Account Flow
  • Loading branch information
dimak1 authored Oct 29, 2024
2 parents 06f3e18 + 8c559bc commit e1c6a86
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
19 changes: 11 additions & 8 deletions strr-web/composables/useBcrosAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export const useBcrosAuth = () => {

/** Logout and then redirect to given page (if redirect provided). */
async function logout (redirect: string) {
localStorage.clear()
account.setCurrentAccount({} as AccountI)
account.userOrgs = []
await keycloak.logout(redirect)
localStorage.removeItem(SessionStorageKeyE.CURRENT_ACCOUNT)
}

/** redirect if account status is suspended */
Expand Down Expand Up @@ -66,13 +68,14 @@ export const useBcrosAuth = () => {
// verify account status
verifyAccountStatus()

console.info('Checking Terms of Service acceptance...')
const isToSAccepted = await checkTermsOfService()

// if Terms not accepted - redirect TOS page
if (!isToSAccepted) {
goToTermsOfService()
return
// do not show Terms for IDIR users
if (keycloak.kcUser.loginSource !== 'IDIR') {
const isToSAccepted = await checkTermsOfService()
// if Terms not accepted - redirect TOS page
if (!isToSAccepted) {
goToTermsOfService()
return
}
}

// if user has not picked an account - go to Account Select
Expand Down
2 changes: 1 addition & 1 deletion strr-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strr-web",
"version": "0.1.41",
"version": "0.1.42",
"description": "Short Term Rental Registration UI - Mono repo workspace",
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
2 changes: 1 addition & 1 deletion strr-web/stores/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const useBcrosAccount = defineStore('bcros/account', () => {
let storedUserProfile: MeI | void = JSON.parse(sessionStorage.getItem(SessionStorageKeyE.USER_PROFILE) || 'null')

// if no stored user profile or account ID is provided, fetch user profile
if (!storedUserProfile || !!currentAccountId) {
if ((!storedUserProfile || !!currentAccountId) || !currentAccount.value.id) {
storedUserProfile = await getMe()
if (storedUserProfile) {
sessionStorage.setItem(SessionStorageKeyE.USER_PROFILE, JSON.stringify(storedUserProfile))
Expand Down
1 change: 1 addition & 0 deletions strr-web/stores/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const useBcrosKeycloak = defineStore('bcros/keycloak', () => {
sessionStorage.removeItem(SessionStorageKeyE.USER_PROFILE)
// TODO: TC - investigate if this fix for "not quite logged out redirect issue"
sessionStorage.removeItem(SessionStorageKeyE.CURRENT_ACCOUNT)
localStorage.removeItem(SessionStorageKeyE.CURRENT_ACCOUNT)
}

function syncSessionStorage () {
Expand Down

0 comments on commit e1c6a86

Please sign in to comment.