PHP Laravel 框架 扩展自己需要的 Auth 模块
PHPLaravel框架扩展自己需要的Auth模块 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 框架 扩展自己需要的 Auth 模块 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') ); });
<?php namespace Illuminate\Auth; //放在Laravel/项目名/vendor/laravel/framework/src/Illuminate/Auth 下 ,存名 PlatformUserProvider.php use Illuminate\Database\Connection; use Illuminate\Hashing\HasherInterface; use Illuminate\Auth\GenericUser; use Illuminate\Auth\UserInterface; use Illuminate\Auth\UserProviderInterface; class PlatformUserProvider implements UserProviderInterface { /** * The active database connection. * * @param \Illuminate\Database\Connection */ protected $conn; /** * The hasher implementation. * * @var \Illuminate\Hashing\HasherInterface */ protected $hasher; /** * The table containing the users. * * @var string */ protected $table; /** * Create a new database user provider. * * @param \Illuminate\Database\Connection $conn * @param \Illuminate\Hashing\HasherInterface $hasher * @param string $table * @return void */ public function __construct( Connection $conn, HasherInterface $hasher, $table ) { $this->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 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()); } }
<?php namespace Illuminate\Auth; class GenericUser implements UserInterface { /** * All of the user's attributes. * * @var array */ protected $attributes; /** * Create a new generic User object. * * @param array $attributes * @return void */ public function __construct(array $attributes) { $this->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]); } }
<?php return array( /* |-------------------------------------------------------------------------- | Default Authentication Driver |-------------------------------------------------------------------------- | | This option controls the authentication driver that will be utilized. | This driver manages the retrieval and authentication of the users | attempting to get access to protected areas of your application. | | Supported: "database", "eloquent" | */ //'driver' => 'eloquent', //'driver' => 'database', 'driver' => 'platform', //这里改成自己的driver /* |-------------------------------------------------------------------------- | Authentication Model |-------------------------------------------------------------------------- | | When using the "Eloquent" authentication driver, we need to know which | Eloquent model should 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 Table |-------------------------------------------------------------------------- | | When using the "Database" authentication driver, we need to know which | table should 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', /* |-------------------------------------------------------------------------- | Password Reminder Settings |-------------------------------------------------------------------------- | | Here you may set the settings for password reminders, including a view | that should 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 should 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, ), );

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen



PHP 8.4 bringt mehrere neue Funktionen, Sicherheitsverbesserungen und Leistungsverbesserungen mit einer beträchtlichen Menge an veralteten und entfernten Funktionen. In dieser Anleitung wird erklärt, wie Sie PHP 8.4 installieren oder auf PHP 8.4 auf Ubuntu, Debian oder deren Derivaten aktualisieren. Obwohl es möglich ist, PHP aus dem Quellcode zu kompilieren, ist die Installation aus einem APT-Repository wie unten erläutert oft schneller und sicherer, da diese Repositorys in Zukunft die neuesten Fehlerbehebungen und Sicherheitsupdates bereitstellen.

Visual Studio Code, auch bekannt als VS Code, ist ein kostenloser Quellcode-Editor – oder eine integrierte Entwicklungsumgebung (IDE) –, die für alle gängigen Betriebssysteme verfügbar ist. Mit einer großen Sammlung von Erweiterungen für viele Programmiersprachen kann VS Code c

Dieses Tutorial zeigt, wie XML -Dokumente mit PHP effizient verarbeitet werden. XML (Extensible Markup-Sprache) ist eine vielseitige textbasierte Markup-Sprache, die sowohl für die Lesbarkeit des Menschen als auch für die Analyse von Maschinen entwickelt wurde. Es wird üblicherweise für die Datenspeicherung ein verwendet und wird häufig verwendet

Eine Zeichenfolge ist eine Folge von Zeichen, einschließlich Buchstaben, Zahlen und Symbolen. In diesem Tutorial wird lernen, wie Sie die Anzahl der Vokale in einer bestimmten Zeichenfolge in PHP unter Verwendung verschiedener Methoden berechnen. Die Vokale auf Englisch sind a, e, i, o, u und sie können Großbuchstaben oder Kleinbuchstaben sein. Was ist ein Vokal? Vokale sind alphabetische Zeichen, die eine spezifische Aussprache darstellen. Es gibt fünf Vokale in Englisch, einschließlich Großbuchstaben und Kleinbuchstaben: a, e, ich, o, u Beispiel 1 Eingabe: String = "TutorialPoint" Ausgabe: 6 erklären Die Vokale in der String "TutorialPoint" sind u, o, i, a, o, ich. Insgesamt gibt es 6 Yuan

Wenn Sie ein erfahrener PHP-Entwickler sind, haben Sie möglicherweise das Gefühl, dass Sie dort waren und dies bereits getan haben. Sie haben eine beträchtliche Anzahl von Anwendungen entwickelt, Millionen von Codezeilen debuggt und eine Reihe von Skripten optimiert, um op zu erreichen

CMS steht für Content Management System. Es handelt sich um eine Softwareanwendung oder Plattform, die es Benutzern ermöglicht, digitale Inhalte zu erstellen, zu verwalten und zu ändern, ohne dass dafür fortgeschrittene technische Kenntnisse erforderlich sind. CMS ermöglicht Benutzern das einfache Erstellen und Organisieren von Inhalten

So implementieren Sie die Tabellenfunktion von benutzerdefiniertem Klicken, um Daten in dcatadmin (laravel-admin) hinzuzufügen, wenn Sie DCAT verwenden ...

Laravel -Zeitplan -Aufgabe Ausführen nicht reagierende Fehlerbehebung Bei Verwendung der Zeitplanung von Laravel -Zeitplänen werden viele Entwickler auf dieses Problem stoßen: Zeitplan: Run ...
