Answer the question
In order to leave comments, you need to log in
Why after authorization does not redirect to the desired page?
Made authorization on laravel.
The controller is like this:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Auth;
class UserController extends Controller
{
public function authget() {
$data = [
'pagetitle' => 'Авторизация'
];
return view('pages.auth', $data);
}
public function authpost(Request $request) {
$rules = array('username' => 'required', 'password' => 'required');
$auth = Auth::attempt(array(
'username' => $request->only('username')['username'],
'password' => $request->only('password')['password']
), false);
if (!Auth::check()) {
return redirect()->route('user.auth.get');
}
return redirect()->route('pages.admin');
}
}
Route::get('/', ['uses' => '[email protected]', 'as' => 'pages.index']);
Route::post('/admin', ['uses' => '[email protected]', 'as' => 'index.store']);
Route::get('/admin', ['uses' => '[email protected]', 'as' => 'pages.admin', 'middleware' => 'auth']);
Route::get('/service_{id}/delete', ['uses' => '[email protected]', 'as' => 'service.delete']);
Route::get('/service/add', ['uses' => '[email protected]', 'as' => 'service.add']);
Route::post('/form/call', ['uses' => '[email protected]', 'as' => 'index.call']);
Answer the question
In order to leave comments, you need to log in
Try like this:
if ( ! $auth)
{
return redirect()->route('user.auth.get');
}
if ( ! Auth::check())
{
return redirect()->route('user.auth.get');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question