Skip to content

Commit

Permalink
- updated example Status API URL (#789)
Browse files Browse the repository at this point in the history
- app version = 5.5.20
- updated updateUser error text
- check SESSION_SYNCED before fetching user info
- misc cleanup

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Jan 6, 2025
1 parent b394b94 commit a19d711
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VUE_APP_LEGAL_API_URL="https://legal-api-dev.apps.silver.devops.gov.bc.ca"
VUE_APP_LEGAL_API_VERSION_2="/api/v2"
VUE_APP_NAMEX_API_URL="https://namex-dev.apps.silver.devops.gov.bc.ca"
VUE_APP_NAMEX_API_VERSION="/api/v1"
VUE_APP_STATUS_API_URL="https://status-api-dev.apps.silver.devops.gov.bc.ca"
VUE_APP_STATUS_API_URL="https://status-api-dev.apps.gold.devops.gov.bc.ca"
VUE_APP_STATUS_API_VERSION="/api/v1"
VUE_APP_REGISTRIES_SEARCH_API_URL="https://bcregistry-dev.apigee.net/registry-search"
VUE_APP_REGISTRIES_SEARCH_API_VERSION="/api/v1"
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-request",
"version": "5.5.19",
"version": "5.5.20",
"private": true,
"appName": "Name Request UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion app/src/mixins/update-user-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class UpdateUserMixin extends Vue {
}
} catch (err) {
// just log the error -- no need to halt app
console.log('Launch Darkly update error =', err) // eslint-disable-line no-console
console.log('Error updating user =', err) // eslint-disable-line no-console
}
}

Expand Down
32 changes: 15 additions & 17 deletions app/src/services/auth-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,22 @@ export default class AuthServices {
* Throws on error.
*/
static async fetchUserInfo (): Promise<any> {
// PREVENT_STORAGE_SYNC flag is set during signout in sbc common components
// when session is state cleared, as a mechanism to prevent returning async
// functions to set tokens
if (sessionStorage.getItem('PREVENT_STORAGE_SYNC')) return null
const url = `${this.authApiUrl}/users/@me`
// don't fetch user info if session isn't synced (ie, user is not logged in)
// to pre-empt a console error and Sentry log
if (sessionStorage.getItem('SESSION_SYNCED') !== 'true') return null

// don't fetch user info if there is no KC token (safety check)
const token = sessionStorage.getItem('KEYCLOAK_TOKEN')
if (token) {
const headers = {
Authorization: `Bearer ${token}`
}
return axios.get(url, { headers: headers })
.then(response => {
if (response?.data) return response.data
throw new Error('Invalid user info')
})
} else {
return null
}
if (!token) return null

const url = `${this.authApiUrl}/users/@me`
const headers = { Authorization: `Bearer ${token}` }

return axios.get(url, { headers: headers })
.then(response => {
if (response?.data) return response.data
throw new Error('Invalid user info')
})
}

/**
Expand Down

0 comments on commit a19d711

Please sign in to comment.