| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Provies a module for giving access to login to the REST API modules.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementes hook_restapi_menu(). Adds the login callback.
|
| 11 |
*/
|
| 12 |
function restapi_login_restapi_menu($may_cache) {
|
| 13 |
if ($may_cache) {
|
| 14 |
$items[] = array(
|
| 15 |
'method' => 'POST',
|
| 16 |
'path' => '=/login',
|
| 17 |
'callback' => 'restapi_login_login',
|
| 18 |
'access' => TRUE,
|
| 19 |
);
|
| 20 |
}
|
| 21 |
|
| 22 |
return $items;
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Implements hook_restapi_help(). Shows help for POST to login.
|
| 27 |
*/
|
| 28 |
function restapi_login_restapi_help() {
|
| 29 |
$help['prototypes'][] = array(
|
| 30 |
'method' => 'POST',
|
| 31 |
'path' => '/=/login',
|
| 32 |
'description' => 'Given "name" and "pass" arguments, uses the "user_login" form to log the client into the system.',
|
| 33 |
);
|
| 34 |
|
| 35 |
return $help;
|
| 36 |
}
|
| 37 |
|
| 38 |
/**
|
| 39 |
* Handles /=/login
|
| 40 |
*/
|
| 41 |
function restapi_login_login($data) {
|
| 42 |
$result = drupal_execute('user_login', $data);
|
| 43 |
print restapi_serialize($result);
|
| 44 |
}
|