M
M
Maxim Kiktev2016-01-07 01:35:48
Laravel
Maxim Kiktev, 2016-01-07 01:35:48

How to redirect after authorization in Laravel 5.2?

tell me how to make a redirect to the main "/" after the user has logged in, the default is / home in routes.php, if I change to / home to / gives an error

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
crimea13, 2016-01-25
@Ne0lite

Mikhail Osher and lynnikvadim redirect works only on open links, if the link is only for authorized users, then this garbage happens:
I'm trying to make an entrance to the admin panel only for authorized users. In routes.php I write the route

Route::get('/adminzone', ['middleware' => 'auth', function() {
    // Доступ разрешён только аутентифицированным пользователям...
    return view('admin.admin_template');
}]);

In /app/Http/Controllers/Auth/AuthController.php
When accessing /adminzone I get:
1) If not authorized, then the authorization form and after login redirect to the root page.
2) If authorized, then immediately redirect to the root.
I write in RedirectIfAuthenticated.php I get an
endless redirect.
Without using the 'middleware' => 'auth' middleware in the route, following the /adminzone link is fine.
Kindly, tell me what is wrong, please.

M
Mikhail Osher, 2016-01-07
@miraage

if (Auth::attempt($credentials)) {
  return redirect('/');
}

L
lynnikvadim, 2016-01-08
@lynnikvadim

In /app/Http/Controllers/Auth/AuthController.php write protected $redirectTo = 'url';(url - the address where you want to go.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question