gpt4 book ai didi

php - Laravel 5.2.29 多重身份验证使用 Auth::guard ('one' ),Auth::guard ('two' )

转载 作者:搜寻专家 更新时间:2023-10-31 21:03:40 26 4
gpt4 key购买 nike

请帮我解决这个问题

我想使用多重身份验证。

我的 Laravel 版本是 5.2.* (5.2.29)

文档中写的我都做

//congig/auth.php
<?php

return [

'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],

'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],

'api' => [
'driver' => 'token',
'provider' => 'users',
],

'admin' => [
'driver' => 'token',
'provider' => 'adminProvider',
],
],

'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],

'adminProvider' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
],

'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
];

But
Auth::guard('api')->attempt(['email'=>som@email.com,...])

出现以下错误

FatalErrorException in AuthController.php line 34:

Call to undefined method Illuminate\Auth\TokenGuard::attempt() What did I do wrong?

最佳答案

您应该更改以下内容:

'admin' => [
'driver' => 'token',
'provider' => 'adminProvider',
],

'admin' => [
'driver' => 'session',
'provider' => 'adminProvider',
],

您不能对 token 使用尝试。

关于php - Laravel 5.2.29 多重身份验证使用 Auth::guard ('one' ),Auth::guard ('two' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36519566/

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