I am working on a dummy project to know more about middlewares. I want to create custom registration for this project.
I changed 1
- User Model
- users Table
- Login Controller
For now I don't need a registration page. I just filled a dummy data in users table. I want to see how this auth middle ware works for a group of routes.
So, After that I tried logging in using the same credentials. I was able to log in however, If I want to navigate other pages its throwing a login in page. Somehow, Auth is getting destroyed.
What am I missing here?
Here is my route file
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::group(['middleware' => ['web','auth']], function () {
Route::view('/home', 'home')->name('home');
Route::view('something','SuperAdmin.something')->name('something');
});
This is my Login Controller
<?php
namespace App\Http\Controllers\Auth;
use Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function login(Request $request){
$email = trim($request->email);
$password = $request->password;
if(Auth::attempt(['email' => $email, 'password' => $password])){
return view('SuperAdmin.dashboard');
}
return redirect()->route('login');
}
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
I am redirecting to {{something}} view from home.blade.php. The Auth works for just one page.
How can I get it working as default?