Ajax Comment System comes with a simple built in authentication driver that allows you to Log in, Sign up and edit your Account. By default this driver is used for the admin panel too.
To log a user in, use the Auth::attempt
method.
$credentials = [
'email' => '[email protected]',
'passowrd' => 'test123',
];
if (Auth::attempt($credentials, true)) {
redirect('index.php');
}
To determine if the user is logged in, use the Auth::check
method:
if (Auth::check()) {
echo 'Welcome!';
}
Once a user is authenticated, you may access its attributes (id, name, email, role, avatar):
$name = Auth::user()->name;
Auth::logout();
Note: Check out
user.php
for a complete example including sign up and account.