Commit 656075f9 authored by Guillaume Wauquier's avatar Guillaume Wauquier
Browse files

Ajout d'une route et d'une fonction dans l'api, pour récuperer les informations d'un utilisateur

parent 34bfa692
......@@ -26,6 +26,17 @@ $app->GET('/api/user/{id}', function ($request, $response, $args) {
return $response->withApiResult(APICaller::run($ptApp, 'user', 'get', $args['id']));
});
/**
* GET userIdGet
* Summary:
* Notes: Get a User
* Output-Formats: [application/json]
*/
$app->GET('/api/user/getByName/{name}', function ($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
return $response->withApiResult(APICaller::run($ptApp, 'user', 'getByName', $args['name']));
});
/**
* POST userPasswordPut
......
......@@ -22,12 +22,30 @@
namespace Pasteque\Server\API;
use \Pasteque\Server\System\DAO\DAOCondition;
/** CRUD API for User. */
class UserAPI extends APIHelper implements API
{
const MODEL_NAME = 'Pasteque\Server\Model\User';
// TODO: add security to prevent updating password with write
public function getByName($name)
{
global $ptApp;
$data = $this->dao->search(static::MODEL_NAME, new DAOCondition('name', '=', $name), 1);
if (count($data) > 0) {
return $data[0];
}
return null;
}
// TODO: add security to prevent updating password with write
/** Update user's password.
* @param \Pasteque\Server\Model\User $user The user.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment