Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring main, adding separate authn/z providers #4522

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

d-g-town
Copy link
Collaborator

No description provided.

Comment on lines 30 to 48
const authenticate = (): void => {
api
.checkAuth("", {}, {})
.then((res) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we refactor these to return promises? just for consistency and so that we're not unexpectedly assuming an async task has finished

Comment on lines 32 to 39
const {
authenticate,
handleLogOut,
isLoggedIn,
isLoading,
hasInfo,
isEmailVerified,
} = useContext(AuthnContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one suggestion that goes along with my other comment - wrap main in AuthnContext, wait for authenticate to complete, if not authenticated then return something other than main (redirect, un-authed page, etc).

This comes with the benefit that we don't need a flag like hasInfo and can instead assume the user is logged in from any child component defined in the router of Main

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can then also have a user object provided by this context that is guaranteed to be defined

@d-g-town d-g-town enabled auto-merge (squash) May 2, 2024 15:23
@d-g-town d-g-town merged commit 3ae6a07 into master May 2, 2024
9 checks passed
@d-g-town d-g-town deleted the dgtown/auth branch May 2, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants