If I got it right the OAuth strategy flow works like this:
1,middleware: ['auth'] on page.vue redirects to /login
2, On login.vue calling $auth.login() redirects to oauth provider
3, redirect_uridefaults to /login so oauth provider redirects back to /login
4, middleware: ['auth'] on login.vue redirects back to where we came from
This seems super unnecessary. The OAuth flow I would like to have:
1, When opening a protected page, middleware/plugin redirects to oauth provider directly (without redirecting to /login first)
2, redirect_uri is set to the current path, so oauth provider redirects back to where we came from
I tried to do this by calling $auth.login() when a protected page mounts. But I can't set redirect_uri dynamically to the current page, it will default to /login. This approach would still save the initial redirect to /login, and I could show a "Logged in successfully, you will be redirected" message when returning to /login which is not ideal but you can see it on some sites. But the automatic redirect back to where we came from doesn't work. I even tried setting it via e.g. $auth.$storage.setUniversal('redirect', route.fullPath) but no luck. I could implement this redirect myself but at this point, I feel like I'm fighting the framework.
If I got it right the OAuth strategy flow works like this:
middleware: ['auth']
onpage.vue
redirects to/login
login.vue
calling$auth.login()
redirects to oauth providerredirect_uri
defaults to/login
so oauth provider redirects back to/login
middleware: ['auth']
onlogin.vue
redirects back to where we came fromThis seems super unnecessary. The OAuth flow I would like to have:
/login
first)redirect_uri
is set to the current path, so oauth provider redirects back to where we came fromI tried to do this by calling
$auth.login()
when a protected page mounts. But I can't setredirect_uri
dynamically to the current page, it will default to/login
. This approach would still save the initial redirect to/login
, and I could show a "Logged in successfully, you will be redirected" message when returning to/login
which is not ideal but you can see it on some sites. But the automatic redirect back to where we came from doesn't work. I even tried setting it via e.g.$auth.$storage.setUniversal('redirect', route.fullPath)
but no luck. I could implement this redirect myself but at this point, I feel like I'm fighting the framework.How can I have this "simple" oauth flow?