29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Authentication<br />

• Introduction<br />

• Authentication Quickstart A> - Routing A> - Views A> - Authenticating A> - Retrieving The<br />

Authenticated User A> - Protecting Routes A> - Authentication Throttling<br />

• Manually Authenticating Users A> - Remembering Users A> - Other Authentication Methods<br />

• HTTP Basic Authentication A> - Stateless HTTP Basic Authentication<br />

• Resetting Passwords A> - Database Considerations A> - Routing A> - Views A> - After<br />

Resetting Passwords<br />

• Social Authentication<br />

• Adding Custom Authentication Drivers<br />

Introduction<br />

Laravel makes implementing authentication very simple. In fact, almost everything is configured<br />

for you out of the box. The authentication configuration file is located at config/auth.php, which<br />

contains several well documented options for tweaking the behavior of the authentication services.<br />

Database Considerations<br />

By default, Laravel includes an App\User Eloquent model in your app directory. This model may be<br />

used with the default Eloquent authentication driver. If your application is not using Eloquent, you<br />

may use the database authentication driver which uses the Laravel query builder.<br />

When building the database schema for the App\User model, make sure the password column is at<br />

least 60 characters in length.<br />

Also, you should verify that your users (or equivalent) table contains a nullable, string remember_-<br />

token column of 100 characters. This column will be used to store a token for “remember me” sessions<br />

being maintained by your application. This can be done by using $table->rememberToken(); in a<br />

migration.<br />

Authentication Quickstart<br />

Laravel ships with two authentication controllers out of the box, which are located in the App\Http\Controllers\Aut<br />

namespace. The AuthController handles new user registration and authentication, while the<br />

PasswordController contains the logic to help existing users reset their forgotten passwords. Each<br />

of these controllers uses a trait to include their necessary methods. For many applications, you will<br />

not need to modify these controllers at all.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!