esbenp / esbenp/larapi

Get user in LoginProxy

Open
#39 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
399
Forks
114
PR merge metrics
No merged PRs in 30d

Description

Hi, I'm interested on get the user to return to angular2 in LoginProxy@proxy, but I did not find which class or object returns this.

I need something like this:

```
[...]
public function proxy($grantType, array $data = [])
{
$data = array_merge($data, [
'client_id' => env('PASSWORD_CLIENT_ID'),
'client_secret' => env('PASSWORD_CLIENT_SECRET'),
'grant_type' => $grantType
]);

$response = $this->apiConsumer->post('/oauth/token', $data);
// dd($response, $data, self::REFRESH_TOKEN);
if (!$response->isSuccessful()) {
throw new InvalidCredentialsException();
}

$data = json_decode($response->getContent());

// Create a refresh token cookie
$this->cookie->queue(
self::REFRESH_TOKEN,
$data->refresh_token,
864000, // 10 days
null,
null,
false,
true // HttpOnly
);


return [
'user' => /* User with this token or refresh token */,
'access_token' => $data->access_token,
'expires_in' => $data->expires_in
];
}

[...]
```

I thought something like `$this->auth->user()` but it seems it's not defined.

What am I doing wrong?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.