-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix: fixed magic link issues in dev environment #32
Conversation
/gcbrun |
Temporary Url for review: https://business-registry-dev--pr-32-64iszjjg.web.app |
Karim, on the preview link, are you able to search for businesses (to affiliate them)? |
No Sev, I can't. I've been using kind of a workaround to test this. What I'm doing is I'm going to the regular dev, https://business-registry-dev.web.app/en-CA, do the steps, get the link there by email, then replace the dev URL with the one here before the token. |
/gcbrun |
Temporary Url for review: https://business-registry-dev--pr-32-64iszjjg.web.app |
@severinbeauvais I haven't been able to fix the search issue in the preview link 😞 I'm pretty sure the issue is with the key. I've tried the API key I have locally and the one from 1Pass, both didn't work. I'm probably going to ping Thor or Dietrich and see what they think. |
@@ -3,7 +3,7 @@ export default defineNuxtRouteMiddleware((to) => { | |||
const { $keycloak } = useNuxtApp() | |||
const localePath = useLocalePath() | |||
if (to.meta.order !== 0 && !$keycloak.authenticated) { | |||
return navigateTo(localePath('/')) |
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.
Does this old function do anything extra (like set URL parameters)?
Does it matter that the old code sometimes returns something and the new code doesn't?
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.
So I changed this Sev to use the new window.location.href
only if the URL has a token.
What the old one is doing basically is the same as the new one except for the fact that window.location.href = localePath('/')
causes a full page reload which is needed in this case.
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 this still needed?
if (token) { | ||
sessionStorage.setItem('affiliationToken', token) | ||
} | ||
window.location.href = localePath('/') |
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.
So, if the path contains a token then you save it to session storage and then reload everything?
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, exactly.
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.
Why so complicated? Why can't the token be handled directly? Why is a reload needed? Could you just push a new route?
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.
Because any route that is not that the main route will give a page 404 error:
Whenever that link is pressed, we will get an error if we don't handle it using a middleware or something else. It's not possible to handle it from the index.vue
file directly as we won't even make it to that file.
When I tried handling that via an actual route, I was getting that error as well since the email returned has a double slash //
. The browser was standardizing the URL and removing org ID part. It's a weird thing really. That's why I moved away from that design as I tried countless things but couldn't manage to deal with all the edge cases properly.
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 shouldn't be an issue now
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 love the new design!
Please resolve this conversation.
I want to understand the new design.
console.error('Error accepting affiliation invitation:', e) | ||
} | ||
} | ||
}) |
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 don't love this design of "check URL parameters + set session storage + reload + check session storage + handle token". It feels complicated and I keep thinking there are edge cases.
Can you check this design with someone else, like Travis?
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.
OK, will check with Travis now and see what he thinks.
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 shouldn't be an issue now
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 love the new design!
Please resolve this conversation.
So what's the new design? Does it still update the URL, reload everything, etc?
/gcbrun |
Temporary Url for review: https://business-registry-dev--pr-32-64iszjjg.web.app |
I'm closing this PR. This is because the whole thing changed. We're moving away from this sessionStorage solution and instead, the magic link format was changed in AUTH API: bcgov/sbc-auth#3166 So, the new PR and what I'm going to merge is this: #34 |
Issue #: /bcgov/entity#24363
I've been getting page not found non-stop in DEV. I changed the whole flow to make things cleaner and simpler.
New flow:
If a user presses refresh by mistake for example, the link will run again. That is not ideal.