-
Notifications
You must be signed in to change notification settings - Fork 1
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
CE-1262 Set up authentication page #6
Conversation
β¦' into feature/CE-1262-set-up-authentication-page
# Conflicts: # src/pages/root/navbar/navbar.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor point on the env vars...
<style> | ||
#preload { | ||
position: fixed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't work there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can try to change this one. You will see overlapping white screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you shouldn't be using Windicss classes in index.html
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used it and it seem to be ok except class fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nutto55 - Did you test is locally where the scripts load instantly or over a slow connection? I don't think you're testing the problem I'm expecting.
# Conflicts: # CHANGELOG.md # package-lock.json # package.json # src/models/Stream.ts # src/models/index.ts # src/pages/root/root.html # src/pages/species-richness/species-richness.ts # windi.config.ts
document.getElementById('preload').style.visibility = 'visible' | ||
document.getElementById('app').style.visibility = 'hidden' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure about the sequence here...
- Isn't
#preload
alreadyvisible
? - Shouldn't
#app
already behidden
? (why not sethidden
onapp
directly in the HTML?) - Aren't the Windicss classes on
#preload
embedded in main.ts? At this point external styles & scripts are still loading
export default { | ||
domain: 'auth.rfcx.org', | ||
clientId: 'LiojdvNUserGnCaLj8ckcxeGPHOKitOc', | ||
audience: 'https://rfcx.eu.auth0.com/api/v2/' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in .env
or private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It don't have to.
const Auth0Plugin = await Auth0.init({ | ||
redirectUri: window.location.origin, | ||
onRedirectCallback: (appState) => { | ||
void router.push(appState?.targetUrl ?? window.location.pathname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void router-push(...)
This is cool. I could never get this working! I think it's because I've be using arrow functions.
export const Auth0: Auth0Plugin = { | ||
init, | ||
routeGuard | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How confident are you that this file is correct?
I don't envy you having to write this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The start script is from official example which is in vue2 and got migrate to vue3 by him: https://github.com/alexeyzimarev/auth0-vue3-ts/tree/master/src. I have try to write it in another way e.g. class based or group them in a function but it is too complicated. Maybe you have a better idea to refactor auth0 config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not without spending a long time on it. Maybe we should review this in the future. Hopefully Auth0 will publish an "official" Vue 3 solution.
</div> | ||
<div class="flex items-center mx-4"> | ||
<button | ||
v-if="!auth?.isAuthenticated" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you avoid auth
being null/undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because initial value of Auth in vuex is undefined which is the same as value when user haven't authenticate yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is auth
the Auth0 object? I don't think that should be in Vuex.
Or is it a user?
FYI - I think Vue doesn't like undefined for Reactive fields. You might need to use null. Or maybe that's only a Vue 2 issue.
url: string | ||
} | ||
|
||
const CORE = 'https://staging-api.rfcx.org' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in .env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, It should be another separate task for setting the env for staging
, production
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add it to the PB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Added it.
const Auth0Plugin = await Auth0.init({ | ||
redirectUri: window.location.origin, | ||
onRedirectCallback: (appState) => { | ||
void router.push(appState?.targetUrl ?? window.location.pathname) | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not keen on making the auth plugin here. This logic should be extracted. You could import createAuthPlugin
so that you can still pass in the router, default URL, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is an outstanding issue, I would say it's this one: #6 (comment). I'm unfamiliar with Auth0 code (and I'm suspicious that maybe no one else has reviewed it either). Maybe we can discuss it after I start proper.
Other than that, I wrote a lot & learned quite a lot :) But all my comments are either questions or tips. I don't think there's anything blocking merge, so I will approve.
β DoD
π Summary
πΈ Screenshots
π Problems
π‘ More ideas
vuex
andpinia
and end up with vuex because I am more familiar with this tool + vuex is implement well to support vue 3 in my opinion.