PHPLaravel framework extends the Auth module required by users.

Source: Internet
Author: User
PHPLaravel framework extends the Auth module LaravelPHPAuth: extend (platform, function ($ app) {$ providernewIlluminateAuthPlatformUserProvider ($ app [db]-connection (), $ app [hash], $ app [config] [auth. table]); returnnewIlluminateAu

PHPLaravel framework extends the Auth module Laravel PHP Auth: extend ('platform', function ($ app) {$ provider = new \ Illuminate \ Auth \ PlatformUserProvider ($ app ['db']-connection (), $ app ['hash'], $ app ['config'] ['auth. table ']); return new \ Illuminate \ Au

PHP Laravel framework extends the required Auth module Laravel PHP
Auth::extend('platform', function($app) {    $provider =  new \Illuminate\Auth\PlatformUserProvider( $app['db']->connection(), $app['hash'],$app['config']['auth.table']);    return new \Illuminate\Auth\Guard($provider, App::make('session.store') );});
 Conn = $ conn; $ this-> table = $ table; $ this-> hasher = $ hasher;}/*** Retrieve a user by their unique identifier. ** @ param mixed $ identifier * @ return \ Illuminate \ Auth \ UserInterface | null */public function retrieveById ($ identifier) {$ user = $ this-> conn-> table ($ this-> table)-> find ($ identifier); if (! Is_null ($ user) {return new GenericUser (array) $ user) ;}}/*** Retrieve a user by their unique identifier and "remember me" token. ** @ param mixed $ identifier * @ param string $ token * @ return \ Illuminate \ Auth \ UserInterface | null */public function retrieveByToken ($ identifier, $ token) {$ user = $ this-> conn-> table ($ this-> table)-> where ('id', $ identifier)-> where ('Remember _ token ', $ token)-> first (); if (! Is_null ($ user) {return new GenericUser (array) $ user) ;}}/*** Update the "remember me" token for the given user in storage. ** @ param \ Illuminate \ Auth \ UserInterface $ user * @ param string $ token * @ return void */public function updateRememberToken (UserInterface $ user, $ token) {$ this-> conn-> table ($ this-> table)-> where ('id', $ user-> getAuthIdentifier ()) -> update (array ('Remember _ token' => $ token ));}/** * Retrieve a user by the given credentials. ** @ param array $ credentials * @ return \ Illuminate \ Auth \ UserInterface | null */public function retrieveByCredentials (array $ credentials) {// First we will add each credential element to the query as a where clause. // Then we can execute the query and, if we found a user, return it in a // generic "user" object that will be utilized by the Guard instances. $ Query = $ this-> conn-> table ($ this-> table); foreach ($ credentials as $ key => $ value) {if (! Str_contains ($ key, 'login _ pwd') {$ query-> where ($ key, $ value );}} // Now we are ready to execute the query to see if we have an user matching // the given credentials. if not, we will just return nulls and indicate // that there are no matching users for these given credential arrays. $ user = $ query-> first (); if (! Is_null ($ user) {return new GenericUser (array) $ user) ;}}/*** Validate a user against the given credentials. ** @ param \ Illuminate \ Auth \ UserInterface $ user * @ param array $ credentials * @ return bool */public function validateCredentials (UserInterface $ user, array $ credentials) {$ plain = $ credentials ['login _ pwd']; return $ this-> hasher-> check ($ plain, $ user-> getAuthPassword ());}}
 attributes = $attributes;}/** * Get the unique identifier for the user. * * @return mixed */public function getAuthIdentifier(){return $this->attributes['id'];}/** * Get the password for the user. * * @return string */public function getAuthPassword(){return $this->attributes['login_pwd'];}/** * Get the token value for the "remember me" session. * * @return string */public function getRememberToken(){return $this->attributes['remember_token'];}/** * Set the token value for the "remember me" session. * * @param  string  $value * @return void */public function setRememberToken($value){$this->attributes['remember_token'] = $value;}/** * Get the column name for the "remember me" token. * * @return string */public function getRememberTokenName(){return 'remember_token';}/** * Dynamically access the user's attributes. * * @param  string  $key * @return mixed */public function __get($key){return $this->attributes[$key];}/** * Dynamically set an attribute on the user. * * @param  string  $key * @param  mixed   $value * @return void */public function __set($key, $value){$this->attributes[$key] = $value;}/** * Dynamically check if a value is set on the user. * * @param  string  $key * @return bool */public function __isset($key){return isset($this->attributes[$key]);}/** * Dynamically unset a value on the user. * * @param  string  $key * @return bool */public function __unset($key){unset($this->attributes[$key]);}}
 'Eloquent', // 'driver '=> 'database', 'driver' => 'platform ', // here change to your own driver/* | Authentication | authentication Model | ---------------------------------------------------------------------- | When using the "Eloquent" Authentication driver, we need to know which | Eloquent model shocould be used to retrieve your users. of course, it | is often just the "User" model but you may use whatever you like. | */'model' => 'user',/* | Authentication | authentication Table | Authentication | When using the "Database" authentication driver, we need to know which | table shocould be used to retrieve your users. we have chosen a basic | default value but you may easily change it to any table you like. | * // 'table' => 'users', 'table' => 'members ', /* | login | Password Reminder Settings | login | Here you may set the settings for password reminders, including a view | that shocould be used as your password reminder e-mail. you will also | be able to set the name of the table that holds the reset tokens. | The "expire" time is the number of minutes that the reminder shocould be | considered valid. this security feature keeps tokens short-lived so | they have less time to be guessed. you may change this as needed. | */'reminder' => array ('email '=> 'Emails. auth. reminder ', 'table' => 'password _ reminders', 'expire '=> 60 ,),);

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.