Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 930 Bytes

authentication.md

File metadata and controls

44 lines (30 loc) · 930 Bytes

Authentication

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.

Authenticating Users

To log a user in, use the Auth::attempt method.

$credentials = [
    'email'    => '[email protected]',
    'passowrd' => 'test123',
];

if (Auth::attempt($credentials, true))  {
    redirect('index.php');
}

Determining If A User Is Authenticated

To determine if the user is logged in, use the Auth::check method:

if (Auth::check()) {
    echo 'Welcome!';
}

Accessing The Logged In User

Once a user is authenticated, you may access its attributes (id, name, email, role, avatar):

$name = Auth::user()->name;

Logging A User Out

Auth::logout();

Note: Check out user.php for a complete example including sign up and account.