Auth Manager
The auth manager handles a users authentication status.
The easiest way to use the Auth Manager is to make sure your Controllers extend
Tomahawk\Routing\Controller
. You then have access to it through $this->auth
.
Otherwise just add the following parameter to the construct method of your Controller
Tomahawk\Auth\AuthInterface
and it will get injected in through the Service Container.
Auth Handlers
Tomahawk ships with 3 Auth Handlers:
- Database - A simple handler using the Illuminate Database Component
- Eloquent - An Eloquent handler if the User Model is extending Illuminate's Eloquent Model
- Doctrine - When your using the Doctrine ORM
Setting Up
Configuration
The config for Auth Manager can be found in the app/config/security.php
and will look like the following.
Creating a User model
Your User class needs to implement the Tomahawk\Auth\UserInterface
interface.
You should have a model which looks something like the following:
Authenticating Users
Manual Authentication
To authenticate a user to pass the username and password to the attempt
method.
Manual Authentication With Extra Checks
You might want to also check other parts of the account:
Checking If User Is Logged In
Checking If User Is Guest
Logout A User
Getting The Logged In User
Logging Out The User
Automatically Logging In A Users
If you already have the user model you can pass this the the auth manager to log them in: