我是laravel的新手,我正在尝试使用laravel基本身份验证进行android应用程序登录。我可以毫无问题地登录我的网站,但是在邮递员基本身份验证中使用相同的用户名和密码,我收到了消息“对不起,您未被授权”。我很困惑,有人可以帮我吗?
基本身份验证中间件:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Factory as AuthFactory;
class BasicAuth
{
protected $auth;
/**
* Create a new middleware instance.
*
* @param \Illuminate\Contracts\Auth\Factory $auth
* @return void
*/
public function __construct(AuthFactory $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $this->auth->basic('phone') ?: $next($request);
}
}
我在邮递员中拨打的路线是:
Route::middleware('basic.auth')->get('/user', function (Request $request) {
return $request->user();
});