bcgov / bcgov/citz-imb-sso-react

Bug: State not set on page refresh

Open
#169 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
11
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## Description

When a user is already authenticated and on a page, triggering a refresh of the page and immediately calling the `getAuthorizationHeaderValue` function will return `Bearer undefined`.

It seems like the function is available before the state is repopulated, so state.accessToken is undefined.

## Priority



`high` - This issue has a substantial impact.

## Package Versions

@bcgov/citz-imb-sso-react: `1.0.1 and newer`
@bcgov/citz-imb-sso-express: `any, not relevant`

## To Reproduce
Steps to reproduce the behavior:
1. Have code that will call getAuthorizationHeaderValue when loading in a component contained within the SSOProvider.
2. Ensure the result is printed out
3. Log in
4. Refresh the page
5. See that the wrong value is received, despite being logged in

This branch of PIMS will demonstrate the issue:
https://github.com/bcgov/PIMS/pull/2700

## Expected Behavior

I would expect this function to wait until it is populated in some way, so not to return a bad value. Maybe it could return a promise instead.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at getAuthorizationHeaderValue and the SSOProvider state initialization, using the PIMS pull request linked in the issue to reproduce the refresh case. Confirm that calling the function immediately after refresh while authenticated does not produce Bearer undefined, and verify the behavior against the stated expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
authentication, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.