Authentication

Getting Authenticated User

Use user method to receive currently logged in user instance.

$user = Auth::user();

Checking If The Current User Is Authenticated

You can quickly check authentication status with check method.

if (Auth::check()) {
    // ...have authenticated user
}

Authenticating Users

Authenticate with User instance

You may want to login existing user with his Assely\Adapter\User instance.

$user = User::find(1);

// Login user
Auth::login($user);

// Login and remember user
Auth::login($user, true);

Authenticate with credentials

You can attempt to login user with credentials. attempt method accepts an array of user login and password values. If the attempt was successful true is returned, if not - false.

// Attemp login
Auth::attempt([
    'user_login' => 'admin',
    'user_password' => 'plainpassword',
]);

// Attemp login and remember
Auth::attempt([
    'user_login' => 'admin',
    'user_password' => 'plainpassword',
], true);

Logout Authenticated User

To logout current user simply call logout method.

Auth::logout();