S
S
suhuxa12017-08-02 09:40:21
Laravel
suhuxa1, 2017-08-02 09:40:21

How in laravel to make it so that after authorization it is thrown to the previous. page?

There are a lot of manuals on this topic on the net, but I have not found a working one. For some reason, all of them work for 10 people, while the other 10 do not. Lara version 5.4. Actually, one of the manuals prompted me for such a bike (but I think there are much easier options). When going to the login page, check where the transition came from. If it was made from somewhere in the admin panel (i.e. at the end of the session), for example, from the address /admin/posts. Then add this value to the session and subsequently redirect it there. If nothing has been added to the session, then a redirect to site.ru/admin.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-08-02
@Sanasol

By default, the transition back works if you go to a page that requires authorization and then log in.
If you just go to the login page, then there is no "back" transition. it doesn’t exist, as it were, at all, because they entered from the login page.

A
Alexey Ukolov, 2017-08-02
@alexey-m-ukolov

Then add this value to the session and subsequently redirect it there.
This has already been done and is called redirect()->intended().
The intended method on the redirector will redirect the user to the URL they were attempting to access before being intercepted by the authentication middleware. A fallback URI may be given to this method in case the intended destination is not available.
https://laravel.com/docs/5.4/authentication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question