How to Implement laravelauth

Source: Internet
Author: User
{Code ...}
// \ App \ Http \ Controllers \ Auth \ AuthController. php/*** Create a new authentication controller instance. ** @ param \ Illuminate \ Contracts \ Auth \ Guard $ auth * @ param \ Illuminate \ Contracts \ Auth \ Registrar $ registrar */public function _ construct (Guard $ auth, registrar $ registrar, Request $ request) {$ this-> auth = $ auth; $ this-> registrar = $ registrar; $ this-> request = $ request;} public function postRegist Er () {$ data = $ this-> request-> all (); // call validator $ validator in App \ Services \ Registrar = $ this-> registrar-> validator ($ data); if ($ validator-> fails ()) {$ this-> throwValidationException ($ this-> request, $ validator );} $ this-> auth-> login ($ this-> registrar-> create ($ data); // Where is the login implemented? Return redirect ('/user');} // \ app \ Providers \ AppServiceProvider. php public function register () {// bind the class App \ Services \ Registrar that implements the Illuminate \ Contracts \ Auth \ Registrar interface, $ this-> app-> bind without auth ('illuminate \ Contracts \ Auth \ Registrar ', 'app \ Services \ Registrar ');}

Reply content:
// \ App \ Http \ Controllers \ Auth \ AuthController. php/*** Create a new authentication controller instance. ** @ param \ Illuminate \ Contracts \ Auth \ Guard $ auth * @ param \ Illuminate \ Contracts \ Auth \ Registrar $ registrar */public function _ construct (Guard $ auth, registrar $ registrar, Request $ request) {$ this-> auth = $ auth; $ this-> registrar = $ registrar; $ this-> request = $ request;} public function postRegist Er () {$ data = $ this-> request-> all (); // call validator $ validator in App \ Services \ Registrar = $ this-> registrar-> validator ($ data); if ($ validator-> fails ()) {$ this-> throwValidationException ($ this-> request, $ validator );} $ this-> auth-> login ($ this-> registrar-> create ($ data); // Where is the login implemented? Return redirect ('/user');} // \ app \ Providers \ AppServiceProvider. php public function register () {// bind the class App \ Services \ Registrar that implements the Illuminate \ Contracts \ Auth \ Registrar interface, $ this-> app-> bind without auth ('illuminate \ Contracts \ Auth \ Registrar ', 'app \ Services \ Registrar ');}

Login implementation
\Illuminate\Auth\Guard430th rows

public function login(UserContract $user, $remember = false)    {        $this->updateSession($user->getAuthIdentifier());        // If the user should be permanently "remembered" by the application we will        // queue a permanent cookie that contains the encrypted copy of the user        // identifier. We will then decrypt this later to retrieve the users.        if ($remember) {            $this->createRememberTokenIfDoesntExist($user);            $this->queueRecallerCookie($user);        }        // If we have an event dispatcher instance set we will fire an event so that        // any listeners will hook into the authentication events and run actions        // based on the login and logout events fired from the guard instances.        $this->fireLoginEvent($user, $remember);        $this->setUser($user);    }

What's the problem? =?

View Source Code: https://github.com/laravel/framework/tree/5.1/src/Illuminate/Auth
Self Extension: http://my.oschina.net/zgldh/blog/379461#OSC_h2_1
Reference third-party implementation: https://cartalyst.com/manual/sentinel/2.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.