![](/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.