wiznox
1 week ago

After login and create session redirect to login

Posted 1 week ago by wiznox

Hi all My laravel app which is i am using apis for jwt token and for web routes for using session but my web login not working first my login code is correct and generate session but auth is redirect to login page please solve my problem

This is my route list

+--------+----------+---------------------+----------------+------------------------------------------------------+----------------+
| Domain | Method   | URI                 | Name           | Action                                               | Middleware     |
+--------+----------+---------------------+----------------+------------------------------------------------------+----------------+
|        | GET|HEAD | admin               | adminlogin     | App\Http\Controllers\Admin\[email protected]     | web            |
|        | GET|HEAD | admin/addUser       |                | App\Http\Controllers\Admin\[email protected]   | web,auth       |
|        | DELETE   | admin/delete        |                | App\Http\Controllers\Admin\[email protected]    | web,auth       |
|        | POST     | admin/doAddUser     |                | App\Http\Controllers\Admin\[email protected] | web,auth       |
|        | GET|HEAD | admin/edit/{id}     |                | App\Http\Controllers\Admin\[email protected]      | web,auth       |
|        | GET|HEAD | admin/home          | admindashboard | App\Http\Controllers\Admin\[email protected]     | web,auth       |
|        | POST     | admin/login         | postLogin      | App\Http\Controllers\Admin\[email protected]   | web            |
|        | POST     | admin/logout        |                | App\Http\Controllers\Admin\[email protected]    | web,auth       |
|        | POST     | admin/profile       |                | App\Http\Controllers\Admin\[email protected]   | web,auth       |
|        | POST     | admin/updateUser    |                | App\Http\Controllers\Admin\[email protected]    | web,auth       |
|        | GET|HEAD | admin/user          |                | App\Http\Controllers\Admin\[email protected]     | web,auth       |
|        | GET|HEAD | api/user            |                | Closure                                              | api,auth:api   |
|        | GET|HEAD | api/v1/user         |                | App\Http\Controllers\[email protected]            | api,jwt.verify |
|        | POST     | api/v1/user         |                | App\Http\Controllers\[email protected]          | api            |
|        | PUT      | api/v1/user         |                | App\Http\Controllers\[email protected]          | api,jwt.verify |
|        | POST     | api/v1/user/login   |                | App\Http\Controllers\[email protected]           | api            |
|        | POST     | api/v1/user/logout  |                | App\Http\Controllers\[email protected]          | api,jwt.verify |
|        | GET|HEAD | api/v1/user/me      |                | App\Http\Controllers\[email protected]              | api,jwt.verify |
|        | GET|HEAD | api/v1/user/refresh |                | App\Http\Controllers\[email protected]         | api,jwt.verify |
|        | DELETE   | api/v1/user/{id}    |                | App\Http\Controllers\[email protected]          | api,jwt.verify |
+--------+----------+---------------------+----------------+------------------------------------------------------+----------------+

This is My login code

    if (isset($request->validator) && $request->validator->fails()) {
    return redirect('/admin')
    ->withErrors($request->validator) // send back all errors to the login form
    ->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form
    }else {
        $userdata = array(
            'email'     => $request->input('email'),
            'password'  => $request->input('password')
        );  
if (Auth::attempt($userdata)) {
    dd(Auth::attempt($userdata));
    return redirect()->intended('admin/home');
} else {        
    return redirect('/admin');
}  

}

Please sign in or create an account to participate in this conversation.