Commit 5a270a91 authored by Open Source Developer's avatar Open Source Developer
Browse files

transfer

parent 5c33da95
......@@ -19,7 +19,7 @@ submitedapplications:
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmittedApplication::getSubmittedApplications'
_controller: '\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications'
requirements:
_user_is_logged_in: 'TRUE'
epal.application_submit:
......
......@@ -9,7 +9,7 @@ use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class SubmittedApplication extends ControllerBase
class SubmitedApplications extends ControllerBase
{
protected $entityTypeManager;
......@@ -29,9 +29,25 @@ class SubmittedApplication extends ControllerBase
public function getSubmittedApplications(Request $request)
{
return "aaaaaaaaaaaaaaaaa" ;
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
return $this->respondWithStatus([
'id' => $epalUser->entity->id(),
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
return $res;
}
}
Markdown is supported
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