![](/img/trans.png)
[英]Laravel 5.6 Auth /admin showing blank page with or without login
[英]How to do auth without database in Laravel 5.6?
我必須使用以下代碼在Laravel中進行默認登錄: php artisan make:auth
,我想使用API再添加1個身份驗證。 在此身份驗證API中,我不需要數據庫即可登錄。
有什么解決方案嗎?
我想制作自定義提供程序並加以保護,但是我被困在App\\Auth
上的AlumniAuthProvider.php
:
<?php
namespace App\Auth;
use Illuminate\Contracts\Auth\User as UserContract;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\UserProvider;
use App\Auth\User;
class AlumniAuthProvider implements UserProvider {
public function alumni()
{
}
public function retrieveById($identifier)
{
}
public function retrieveByToken($identifier, $token)
{
}
public function updateRememberToken(Authenticatable $user, $token)
{
}
public function retrieveByCredentials(array $credentials)
{
}
public function validateCredentials(Authenticatable $user, array $credentials)
{
}
}
和Alumni.php
在App\\Auth
:
<?php
namespace App\Auth;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
class Alumni implements Authenticatable
{
public function getAuthIdentifierName()
{
}
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier()
{
}
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
}
/**
* Get the token value for the "remember me" session.
*
* @return string
*/
public function getRememberToken()
{
}
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @return void
*/
public function setRememberToken($value)
{
}
/**
* Get the column name for the "remember me" token.
*
* @return string
*/
public function getRememberTokenName()
{
}
}
如何進行此自定義API登錄?
在我看來,我編寫的這段代碼是用於第二次身份驗證的,還是我錯了? 也許還有其他方法可以解決這個問題?
我認為在沒有數據庫的情況下進行api登錄是一個壞主意,因為每次用戶通過另一個系統登錄時,都會進行api調用,這將在系統上線時產生更多的流量。 更好的方法是第一次進行api調用,並將數據存儲在數據庫中,然后在用戶重新登錄時從數據庫中調用數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.