bcgov / bcgov/entity

Don't check session storage to determine if a user is logged on

Open
#15,659 1 comment 0 reactions 0 assignees View on GitHub
ENTITY - DO NOT USE good first issue Priority2 techdebt
Dominant language
JavaScript
Stars
23
Forks
62
Avg merge
24m
Merged PRs (30d)
1

Description

## TODO
- [ ] Edit-ui
- [ ] Create-ui
- [ ] Filings-ui

## What is the problem?
In Edit-UI, Filings-UI and Create-Ui, there are methods like this:

```javascript
/** True if user is authenticated. */
isAuthenticated (): boolean {
const keycloakToken = sessionStorage.getItem(SessionStorageKeys.KeyCloakToken)
// FUTURE: also check that token isn't expired!
return !!keycloakToken
},
```

## What is the impact?
As the code comment warns, the Keycloak token doesn't check that the token is still valid.

## Proposed solution
To determine if a user is authenticated or not, we should check the store of the SbcHeader. In filings-ui, there's a store getter for this purpose, but we have yet to use it.

```javascript
/** Returns true is the user is Keycloak authenticated. */
isKeycloakAuthenticated (state, getters, rootState, rootGetters): boolean {
return rootGetters['auth/isAuthenticated']
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.