gpt4 book ai didi

php - 如何更改 token guard 中的 api_token 列

转载 作者:可可西里 更新时间:2023-11-01 07:48:40 25 4
gpt4 key购买 nike

Laravel 5.5

我想改变 TokenGaurd 中使用的 api token 的方向,所以,我创建了一个名为 CafeTokenGaurd 的自定义守卫,它扩展了 TokenGuard,我在其中定义了 __construct 函数,就像我想要的那样,如下所示:

public function __construct(UserProvider $provider, Request $request) {
parent::__construct($provider, $request);
$this->inputKey = 'api_key'; // I want changing this part
$this->storageKey = 'api_key';
}

现在我想从与用户表的关系中定义 api_key,如下所示:

device_user table -> token

我想为用户拥有的每个设备定义特定的 token ,并且我想将 api key 输入和存储 key 设置到用户和设备之间的数据透视表中的这一列,

我应该怎么做?!

谢谢

最佳答案

自版本Laravel 5.7.28 , 你可以简单地在config/auth.php中设置。

'guards' => [
'api' => [
'driver' => 'token',
'input_key' => 'token', // The input name to pass through
'storage_key' => 'token', // The column name to store in database
'provider' => 'users',
],
],

关于php - 如何更改 token guard 中的 api_token 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46319639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com