Redirect route after login using nuxt auth module - vue.js

I use nuxt auth module when I route to a guard page when I don't log in the login page is open but if I don't log in and go to another page not guarded and login successfully, automatically redirect me to the last guarded page I was open before if there is any solution for that? I want to go to the last page I was open after login successfully

Related

Nuxt : Check route is redirected from other routes or directly load?

I'm face up with a problem when login.
If user is authenticated, I will let them redirect to home page.
And if they come from another protected route (homepage, other routes) and after logined, I want it redirect to exactly the route they came from.
My solution is:
In auth.js middleware, I will save to cookie the route they come from like this
app.$cookie.set("historyRoute", app.router.history.current.path)
In login.vue I will check if exist historyRoute to let them redirect then remove historyRoute from cookie.
But problem is that user will come from other protected routes and they do not take login action at that time, they make refreshing Login page many times and historyRoute will still exist in cookie.
So I want to know how to determine when visitors directly reload Login page to remove historyRoute in cookie.
Or if you have another solution, please suggest me know. Thanks.
Update flow:
Visitor access link /users/setting
-> check Auth
-> if Not Auth
-> redirect 302 to /Login
-> After login (I need to know they directly come from login page or from /user/setting then redirect to login page)
-> redirect back to users/setting

Laravel 8 - inertia-jetstream-fortify, redirect to a particular URL before login (i.e. On hit of main URL ex.-www.something.com)

I have a Single sign-in laravel application which is, say for example app-A. And my main application app-B. Now, whenever a user visits www.aap-B.com, I want the user to reach to the login page of app-A.
Since app-B is built using laravel fortify whenever I first hit the site url of app-B it takes me to the login page of app-b. How to edit this login route in laravel since it is coming from vendor/laravel/fortify folder. How to make app-B follow the first endpoint to direct to URL of app-A without going to the defult login route when we hit the URl of app-B for the first time.
I don't know where can I edit this login route in app-B. Any piece of advice would be of great help.

How to use FirebaseUI in redirect mode without a dedicated sign-in page?

I want to use FirebaseUI in redirect mode, as opposed to the current popup mode I'm using. But I don't want to have a separate dedicated login URL, instead I want the user to be able to log in from any URL (using a custom dialog as the UI container for FirebaseUI).
The problem I run into is that when starting the login process, I show the dialog and the user selects their auth provider, gets redirected to the auth website, but then they are redirected back to the original URL on my website.
Now the UI container dialog is not displayed and firebaseUI.start() doesn't get called because the webpage doesn't know that the user is in the process of logging in. The result is that nothing happens - the user is halfway through the login process.
Is there any way I can specify a URL for the first redirect? I'm not talking about the final signInSuccessUrl config parameter, but something similar for the first redirect back to my website?
That way I'd be able to send the original URL that started the login process along with a flag or something that tells the webpage that the user is in the middle of a login flow so that it can display the login process UI container and call firebaseUI.start() to perform the last redirect.
You can start FirebaseUI from any URL but the underlying signInWithRedirect always return to the same URL. Calling start on redirect will complete the sign in. If you have some condition, where you don't always display the sign in UI, you can use some flag pendingRedirect which you save in sessionStorage and check before rendering the UI to complete the sign-in on return. You would clear that after rendering.

Router authorizeStep from other app root keeps triggering

My Aurelia project is split up in 2 app roots, both with their own route structure.
App root 1 contains all screens where you don't have to be authenticated (login, reset pwd,...) App root 2 all the other screens.
I'm blocking access to routes on app root 2 when you are not authenticated with an authorizeStep. In this step, I set the root to app root 1 when you are not authenticated. App root 1 has a login view as default route, so this works quite well. So, when you are not authenticated and try to navigate to a deep url in app root 2, this happens:
App Root 2 configures it's routes and tries to navigate to the deep url
The authorizeStep triggers, you are not authenticated, the route is cancelled and an aurelia.setRoot() happens to app root 1
App root 1 configures it's router and navigates you to the default route, the login page
The problem is manually logging out. When this button, residing in app root 2, is clicked. I clear user data, therefore you are not authenticated anymore. Following that step, I manually set the root to app root 1, and there I get an infinite loop:
App root 1 configures it's router and navigates you to the default route, the login page
The authorizeStep triggers from app root 2!, you are not authenticated, the route is cancelled and an aurelia.setRoot() happens to app root 1
App root 1 configures it's router and navigates you to the default route, the login page
...
The problem is that the authorizeStep from root 2 triggers when navigating in root 1. I looked for a way for removing the authorizestep, but I don't think the framework currently exposes this. I find it very curious that this issue only occurs when clicking logout, deep linking and redirecting to login works as expected.
I created a reproducable gist for clarity, click the logout button and you will see the console infinitely repeating the authorizestep.
https://gist.run/?id=1a551dcc4bec7d191ab680a937b19cfc
Turns out you need to clear the steps yourself, this isn't done in a router.clear(), which the aurelia.setRoot() internally calls.
Fortunately you actually can do this yourself, with:
this.pipelineProvider.reset();
I don't find this behavior logical though, so I created an issue for it: https://github.com/aurelia/router/issues/465

Laravel authentication routing after click login button

I have 2 Laravel application inside var/www/html directory.
In the address bar, if we type localhost/first the Laravel authentication will be displayed and the URL is http://localhost/first/public/auth/login but after i click submit button the URL become http://localhost/auth/login and it shows a error:
The requested URL /auth/login was not found on this server.
can you suggest me what is wrong?
In the form you have the post url as /auth/login
Just keep post url as blank or give complete path in the form open tag /first/public/auth/login.
If / is there it will take the path from the root rather than going relative to the app root.
Can give correct update if you can post your login form's blade template also with the question