Я делаю логин с паспортом (в API), я пытаюсь получить токены, сгенерированные сервером аутентификации. Однако я не могу добавить дополнительные параметры к запросу, который является экземпляром FormRequest
.
С другой стороны, если я изменю свой запрос на экземпляр Request
, он будет работать.
Итак, мой вопрос, как я могу добавить параметры в мой запрос $loginRequest
(который является экземпляром FormRequest
)
$loginRequest->request->add($params);
Здесь мой код:
class AuthController extends Controller
{
use ThrottlesLogins;
public function store(LoginRequest $loginRequest)
{
$loginRequest->validated();
if ($this->hasTooManyLoginAttempts($loginRequest)) {
$this->fireLockoutEvent($loginRequest);
return $this->sendLockoutResponse($loginRequest);
}
if (Auth::attempt($this->credentials($loginRequest))){
$client = $this->getClient($loginRequest->name);
$params = [
'grant_type' => 'password',
'client_id' => $client->id,
'client_secret' => $client->secret,
'username' => $loginRequest->email,
'password' => $loginRequest->password,
'scopes' => 'fd',
];
$loginRequest->request->add($params);
$req = Request::create('oauth/token', 'POST');
$response = Route::dispatch($req)->getContent();
return $response;
}
$this->incrementLoginAttempts($loginRequest);
$this->sendFailedLoginResponse($loginRequest);
}
}