Skip to content
Snippets Groups Projects
Commit f6630798 authored by Artem Konenko's avatar Artem Konenko Committed by Роман Штейнберг
Browse files

#167 Add course and group to API auth/userinfo

parent 05fa9fd1
Branches
Tags
No related merge requests found
......@@ -6,10 +6,22 @@ class Controller_Api_V0_Auth extends Controller_Handler_Api
* @api {get} api/v0/auth/userinfo?token=:token&login=:login&password=:password Check authorisation and get user info
* @apiName Get user info
* @apiGroup Auth
* @apiVersion 0.1.0
* @apiVersion 0.1.1
* @apiParam {String} token Api key
* @apiParam {String} login User's login
* @apiParam {String} password User's password
*
* @apiSuccess (200) {String} LastName
* @apiSuccess (200) {String} FirstName
* @apiSuccess (200) {String} SecondName
* @apiSuccess (200) {Boolean} IsEnabled
* @apiSuccess (200) {String="teacher", "student"} Type
* @apiSuccess (200) {String} TeacherID If user is a teacher
* @apiSuccess (200) {String} StudentID If user is a student
* @apiSuccess (200) {String} Grade If user is a student
* @apiSuccess (200) {String} GradeID If user is a student
* @apiSuccess (200) {String} Group If user is a student
* @apiSuccess (200) {String} GroupID If user is a student
*/
public function action_get_userinfo() {
if ( !$this->user->isAdmin() ) // ToDo: we should use apikey mask for checking rights
......@@ -25,10 +37,10 @@ class Controller_Api_V0_Auth extends Controller_Handler_Api
$info = (object)Model_Account::with($id);
$res = (object)['LastName' => $info->LastName,
'FirstName' => $info->FirstName,
'SecondName' => $info->SecondName,
'IsEnabled' => $info->IsEnabled,
'Type' => $info->Type];
'FirstName' => $info->FirstName,
'SecondName' => $info->SecondName,
'IsEnabled' => $info->IsEnabled,
'Type' => $info->Type];
switch($info->Type )
{
......@@ -37,6 +49,11 @@ class Controller_Api_V0_Auth extends Controller_Handler_Api
break;
case 'student':
$res->StudentID = $info->StudentID;
$student = Model_Student::load($info->StudentID);
$res->Grade = $student->GradeNum;
$res->GradeID = $student->GradeID;
$res->Group = $student->GroupNum;
$res->GroupID = $student->GroupID;
break;
}
......
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