Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit d5dc608

Browse files
committed
Add a method for Northstar's auth/verify endpoint.
1 parent b28fdd3 commit d5dc608

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/modules/dosomething/dosomething_northstar/dosomething_northstar.module

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@ function dosomething_northstar_libraries_info() {
4343
return $libraries;
4444
}
4545

46+
47+
/**
48+
* Verify the given credentials against Northstar, returning the authorized
49+
* user account if one exists.
50+
*
51+
* @param array $credentials
52+
* @return mixed|null
53+
*/
54+
function dosomething_northstar_verify_user($credentials) {
55+
$client = _dosomething_northstar_build_http_client();
56+
57+
$response = drupal_http_request($client['base_url'] . '/auth/verify', [
58+
'headers' => $client['headers'],
59+
'method' => 'POST',
60+
'data' => json_encode($credentials),
61+
]);
62+
63+
if($response->code !== '200') {
64+
return null;
65+
}
66+
67+
return json_decode($response->data);
68+
}
69+
4670
/**
4771
* Send user registration events to northstar.
4872
*/

0 commit comments

Comments
 (0)