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 159<br />

.<br />

15 */<br />

16 public function boot()<br />

17 {<br />

18 Auth::extend('riak', function($app) {<br />

19 // Return an instance of Illuminate\Contracts\Auth\UserProvider...<br />

20 return new RiakUserProvider($app['riak.connection']);<br />

21 });<br />

22 }<br />

23<br />

24 /**<br />

25 * Register bindings in the container.<br />

26 *<br />

27 * @return void<br />

28 */<br />

29 public function register()<br />

30 {<br />

31 //<br />

32 }<br />

33 }<br />

After you have registered the driver with the extend method, you may switch to the new driver in<br />

your config/auth.php configuration file.<br />

The User Provider Contract<br />

The Illuminate\Contracts\Auth\UserProvider implementations are only responsible for fetching<br />

a Illuminate\Contracts\Auth\Authenticatable implementation out of a persistent storage system,<br />

such as MySQL, Riak, etc. These two interfaces allow the Laravel authentication mechanisms<br />

to continue functioning regardless of how the user data is stored or what type of class is used to<br />

represent it.<br />

Let’s take a look at the Illuminate\Contracts\Auth\UserProvider contract:<br />

.<br />

1

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

Saved successfully!

Ooh no, something went wrong!