Skip to content

Commit d76867e

Browse files
committed
Login Proxy
1 parent 3bda63c commit d76867e

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

app/Http/Controllers/API/LoginAPIController.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,40 @@ public function proxy($grantType, array $data = [])
6363
}
6464

6565
// Create a refresh token cookie
66-
// $this->cookie->queue(self::REFRESH_TOKEN, $data["refresh_token"], 864000, null, null, false, true); // HttpOnly
66+
// $this->cookie->queue(self::REFRESH_TOKEN, $data["refresh_token"], 864000, null, null, false, true); // HttpOnly
6767

68-
return [
69-
'access_token' => $data["access_token"],
70-
'expires_in' => $data["expires_in"]
68+
$data = [
69+
'access_token' => $result["access_token"],
70+
'expires_in' => $result["expires_in"]
7171
];
72+
73+
74+
75+
return $this->sendResponse($data, 'Success');
7276
}
7377

7478
private function getAccessToken($data)
7579
{
7680
$http = new Client();
7781

7882
try {
79-
$response = $http->post('http://localhost:8000/oauth/token', [
80-
'form_params' => $data
83+
$response = $http->post('http://' . $_SERVER["SERVER_ADDR"] . '/oauth/token', [
84+
'form_params' => $data,
85+
'headers' => [
86+
'Host' => 'larapi.local'
87+
]
8188
]);
8289

8390
$result = json_decode((string) $response->getBody(), true);
91+
92+
return $result;
93+
94+
8495
} catch (\Exception $e) {
96+
97+
var_dump($e->getMessage());
98+
die();
99+
85100
return null;
86101
}
87102
return $result;

0 commit comments

Comments
 (0)