T
T
teertsneerg2020-02-22 22:44:38
Laravel
teertsneerg, 2020-02-22 22:44:38

Why doesn't laravel redirect after logging in?

Hello.

Made "custom" authorization, according to the Laravel documentation (version 5.4)

public function authenticate(Request $request)
    {
        if (Auth::attempt(['email' => $request->login, 'password' => $request->password]) || Auth::attempt(['phone' => $request->login, 'password' => $request->password])) {
            return redirect()->intended('/home');
        }
        else {
            return redirect()->intended('/login');
        }
    }

Authorization is at the link url.ru/login. After I click the "login" button, the page is updated (url.ru/login), but the view is not rendered, just an empty page with the same URL, but if after that you update the page manually, then a redirect will occur to the right place (if the correct data is entered to the url.ru/home page, if not, then back to url.ru/login). What is the problem?

Or maybe I'm doing something wrong

UPD: routes
Route::get('/', function () {
    return redirect('/login');
});
Auth::routes();
Route::get('/logout', 'Auth\[email protected]');
Route::post('/sendCode', 'SmsCode\[email protected]');
Route::post('/verifCode', 'SmsCode\[email protected]');
Route::get('/home', '[email protected]')->name('home');
Route::get('/cabinet', '[email protected]')->name('chat');

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question