@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | echo json_encode(array("failed" => "Requested job application does not belong to this user"), JSON_FORCE_OBJECT); |
| 49 | 49 | exit; |
| 50 | 50 | } |
| 51 | - }else if ($user->getUser_role() === "administrator") { |
|
| 51 | + } else if ($user->getUser_role() === "administrator") { |
|
| 52 | 52 | $jobPoster = JobPosterController::getJobPosterById($locale, $jobPosterId); |
| 53 | 53 | if ($jobPoster->getManager_user_id() != $user->getUser_id()) { |
| 54 | 54 | header('HTTP/1.0 401 Unauthorized'); |
| 55 | 55 | echo json_encode(array("failed" => "This user is not authorized to view applications for this job"), JSON_FORCE_OBJECT); |
| 56 | 56 | exit; |
| 57 | 57 | } |
| 58 | - }else { |
|
| 58 | + } else { |
|
| 59 | 59 | header('HTTP/1.0 401 Unauthorized'); |
| 60 | 60 | echo json_encode(array("failed" => "This user does not have permissions to view job applications"), JSON_FORCE_OBJECT); |
| 61 | 61 | exit; |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $json = json_encode($fullJobApplication, JSON_PRETTY_PRINT); |
| 74 | 74 | echo($json); |
| 75 | - }else { |
|
| 75 | + } else { |
|
| 76 | 76 | header('HTTP/1.0 401 Unauthorized'); |
| 77 | 77 | echo json_encode(array("failed" => "Invalid token"), JSON_FORCE_OBJECT); |
| 78 | 78 | exit; |
| 79 | 79 | } |
| 80 | - }else { |
|
| 80 | + } else { |
|
| 81 | 81 | header('HTTP/1.0 401 Unauthorized'); |
| 82 | 82 | echo json_encode(array("failed" => 'Invalid token, please reauthorize user'), JSON_FORCE_OBJECT); |
| 83 | 83 | exit; |
| 84 | 84 | } |
| 85 | - }else { |
|
| 85 | + } else { |
|
| 86 | 86 | header('HTTP/1.0 401 Unauthorized'); |
| 87 | 87 | echo json_encode(array("failed" => 'No authorization token provided'), JSON_FORCE_OBJECT); |
| 88 | 88 | exit; |
@@ -52,23 +52,23 @@ |
||
| 52 | 52 | |
| 53 | 53 | echo($json); |
| 54 | 54 | |
| 55 | - }else { |
|
| 55 | + } else { |
|
| 56 | 56 | header('HTTP/1.0 401 Unauthorized'); |
| 57 | 57 | echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
| 58 | 58 | exit; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - }else { |
|
| 61 | + } else { |
|
| 62 | 62 | header('HTTP/1.0 401 Unauthorized'); |
| 63 | 63 | echo json_encode(array("failed"=>"No user id provided"), JSON_FORCE_OBJECT); |
| 64 | 64 | exit; |
| 65 | 65 | } |
| 66 | - }else { |
|
| 66 | + } else { |
|
| 67 | 67 | header('HTTP/1.0 401 Unauthorized'); |
| 68 | 68 | echo json_encode(array("failed"=>'Invalid token, please reauthorize user'), JSON_FORCE_OBJECT); |
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | - }else { |
|
| 71 | + } else { |
|
| 72 | 72 | header('HTTP/1.0 401 Unauthorized'); |
| 73 | 73 | echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
| 74 | 74 | exit; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $result = WorkSampleController::getAllWorkSamplesForJobApplication($jobPosterApplicationId, $locale); |
| 36 | 36 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 37 | 37 | echo($json); |
| 38 | - }else { |
|
| 38 | + } else { |
|
| 39 | 39 | $result = array(); |
| 40 | 40 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 41 | 41 | echo($json); |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 61 | 61 | echo($json); |
| 62 | - }else { |
|
| 62 | + } else { |
|
| 63 | 63 | header('HTTP/1.0 403 Forbidden'); |
| 64 | 64 | echo json_encode(array("failed" => "Only Draft applications can be modified."), JSON_FORCE_OBJECT); |
| 65 | 65 | exit; |
| 66 | 66 | } |
| 67 | - }else { |
|
| 67 | + } else { |
|
| 68 | 68 | $result = array(); |
| 69 | 69 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 70 | 70 | echo($json); |
@@ -95,12 +95,12 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 97 | 97 | echo($json); |
| 98 | - }else { |
|
| 98 | + } else { |
|
| 99 | 99 | header('HTTP/1.0 403 Forbidden'); |
| 100 | 100 | echo json_encode(array("failed" => "Only Draft applications can be modified."), JSON_FORCE_OBJECT); |
| 101 | 101 | exit; |
| 102 | 102 | } |
| 103 | - }else { |
|
| 103 | + } else { |
|
| 104 | 104 | $result = array(); |
| 105 | 105 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 106 | 106 | echo($json); |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | $result = ContentController::getContentByLocale($locale); |
| 40 | 40 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 41 | 41 | echo($json); |
| 42 | - }else { |
|
| 42 | + } else { |
|
| 43 | 43 | $result = array(); |
| 44 | 44 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 45 | 45 | echo($json); |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | |
| 43 | 43 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 44 | 44 | echo($json); |
| 45 | - }else { |
|
| 45 | + } else { |
|
| 46 | 46 | $result = array(); |
| 47 | 47 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 48 | 48 | echo($json); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 38 | 38 | header("Content-length:" . strlen($json)); |
| 39 | 39 | echo($json); |
| 40 | - }else { |
|
| 40 | + } else { |
|
| 41 | 41 | $result = array(); |
| 42 | 42 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 43 | 43 | echo($json); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $result = JobPosterController::createJobPoster($jobPoster); |
| 107 | 107 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 108 | 108 | echo($json); |
| 109 | - }else { |
|
| 109 | + } else { |
|
| 110 | 110 | $result = array(); |
| 111 | 111 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 112 | 112 | echo($json); |
@@ -29,108 +29,108 @@ |
||
| 29 | 29 | $requestParams = substr($requestURI, strlen($context) + 1); |
| 30 | 30 | |
| 31 | 31 | switch ($requestMethod) { |
| 32 | - case 'GET': |
|
| 33 | - if (isset($_SERVER["HTTP_AUTHORIZATION"])) { |
|
| 34 | - $jwt = JWTUtils::getTokenFromRequest($_SERVER["HTTP_AUTHORIZATION"]); |
|
| 32 | + case 'GET': |
|
| 33 | + if (isset($_SERVER["HTTP_AUTHORIZATION"])) { |
|
| 34 | + $jwt = JWTUtils::getTokenFromRequest($_SERVER["HTTP_AUTHORIZATION"]); |
|
| 35 | 35 | |
| 36 | - $open_id = Utils::getParameterFromRequest($requestParams, $user_id_param_index); |
|
| 36 | + $open_id = Utils::getParameterFromRequest($requestParams, $user_id_param_index); |
|
| 37 | 37 | |
| 38 | - if (strlen($requestParams) > 1) { |
|
| 38 | + if (strlen($requestParams) > 1) { |
|
| 39 | 39 | |
| 40 | - if (strlen($open_id) > 0) { |
|
| 40 | + if (strlen($open_id) > 0) { |
|
| 41 | 41 | |
| 42 | - $user = new User(); |
|
| 42 | + $user = new User(); |
|
| 43 | 43 | |
| 44 | - $user->setOpen_id($open_id); |
|
| 44 | + $user->setOpen_id($open_id); |
|
| 45 | 45 | |
| 46 | - if (JWTUtils::validateJWT($jwt, $user)) { |
|
| 46 | + if (JWTUtils::validateJWT($jwt, $user)) { |
|
| 47 | 47 | |
| 48 | - $result = UserController::getUserByOpenId($user); |
|
| 48 | + $result = UserController::getUserByOpenId($user); |
|
| 49 | 49 | |
| 50 | - $json = json_encode($result, JSON_PRETTY_PRINT); |
|
| 50 | + $json = json_encode($result, JSON_PRETTY_PRINT); |
|
| 51 | 51 | |
| 52 | - echo($json); |
|
| 52 | + echo($json); |
|
| 53 | + |
|
| 54 | + }else { |
|
| 55 | + header('HTTP/1.0 401 Unauthorized'); |
|
| 56 | + echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
|
| 57 | + exit; |
|
| 58 | + } |
|
| 53 | 59 | |
| 54 | 60 | }else { |
| 55 | 61 | header('HTTP/1.0 401 Unauthorized'); |
| 56 | - echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
|
| 62 | + echo json_encode(array("failed"=>"No user id provided"), JSON_FORCE_OBJECT); |
|
| 57 | 63 | exit; |
| 58 | 64 | } |
| 59 | - |
|
| 60 | 65 | }else { |
| 61 | 66 | header('HTTP/1.0 401 Unauthorized'); |
| 62 | - echo json_encode(array("failed"=>"No user id provided"), JSON_FORCE_OBJECT); |
|
| 67 | + echo json_encode(array("failed"=>'Invalid token, please reauthorize user'), JSON_FORCE_OBJECT); |
|
| 63 | 68 | exit; |
| 64 | 69 | } |
| 65 | 70 | }else { |
| 66 | 71 | header('HTTP/1.0 401 Unauthorized'); |
| 67 | - echo json_encode(array("failed"=>'Invalid token, please reauthorize user'), JSON_FORCE_OBJECT); |
|
| 72 | + echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
|
| 68 | 73 | exit; |
| 69 | 74 | } |
| 70 | - }else { |
|
| 71 | - header('HTTP/1.0 401 Unauthorized'); |
|
| 72 | - echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
|
| 73 | - exit; |
|
| 74 | - } |
|
| 75 | - break; |
|
| 76 | - case 'POST': |
|
| 77 | - if (isset($_SERVER["HTTP_AUTHORIZATION"])) { |
|
| 78 | - $jwt = JWTUtils::getTokenFromRequest($_SERVER["HTTP_AUTHORIZATION"]); |
|
| 75 | + break; |
|
| 76 | + case 'POST': |
|
| 77 | + if (isset($_SERVER["HTTP_AUTHORIZATION"])) { |
|
| 78 | + $jwt = JWTUtils::getTokenFromRequest($_SERVER["HTTP_AUTHORIZATION"]); |
|
| 79 | 79 | |
| 80 | - $jsonBody = file_get_contents('php://input'); |
|
| 81 | - if (strlen($jsonBody) > 1) { |
|
| 80 | + $jsonBody = file_get_contents('php://input'); |
|
| 81 | + if (strlen($jsonBody) > 1) { |
|
| 82 | 82 | |
| 83 | - $credentials = json_decode($jsonBody, TRUE); //convert JSON into array |
|
| 84 | - //var_dump($credentials); |
|
| 85 | - if ($credentials !== null) { |
|
| 83 | + $credentials = json_decode($jsonBody, TRUE); //convert JSON into array |
|
| 84 | + //var_dump($credentials); |
|
| 85 | + if ($credentials !== null) { |
|
| 86 | 86 | |
| 87 | - $user = new User(); |
|
| 87 | + $user = new User(); |
|
| 88 | 88 | |
| 89 | - $user->setOpen_id($credentials["sub"]); |
|
| 90 | - $user->setName($credentials["name"]); |
|
| 91 | - $user->setEmail($credentials["email"]); |
|
| 92 | - $user->setUser_role($credentials["user_role"]); |
|
| 89 | + $user->setOpen_id($credentials["sub"]); |
|
| 90 | + $user->setName($credentials["name"]); |
|
| 91 | + $user->setEmail($credentials["email"]); |
|
| 92 | + $user->setUser_role($credentials["user_role"]); |
|
| 93 | 93 | |
| 94 | - if (JWTUtils::validateJWT($jwt, $user)) { |
|
| 94 | + if (JWTUtils::validateJWT($jwt, $user)) { |
|
| 95 | 95 | |
| 96 | - $result = UserController::getUserByOpenId($user); |
|
| 96 | + $result = UserController::getUserByOpenId($user); |
|
| 97 | 97 | |
| 98 | - $json = json_encode($result, JSON_PRETTY_PRINT); |
|
| 98 | + $json = json_encode($result, JSON_PRETTY_PRINT); |
|
| 99 | 99 | |
| 100 | - echo($json); |
|
| 100 | + echo($json); |
|
| 101 | + }else { |
|
| 102 | + header('HTTP/1.0 401 Unauthorized'); |
|
| 103 | + echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
|
| 104 | + exit; |
|
| 105 | + } |
|
| 101 | 106 | }else { |
| 102 | - header('HTTP/1.0 401 Unauthorized'); |
|
| 103 | - echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
|
| 107 | + header('HTTP/1.0 400 Bad Request'); |
|
| 108 | + echo json_encode(array("failed"=>"Bad Reqest"), JSON_FORCE_OBJECT); |
|
| 104 | 109 | exit; |
| 105 | 110 | } |
| 111 | + |
|
| 106 | 112 | }else { |
| 107 | 113 | header('HTTP/1.0 400 Bad Request'); |
| 108 | 114 | echo json_encode(array("failed"=>"Bad Reqest"), JSON_FORCE_OBJECT); |
| 109 | 115 | exit; |
| 110 | 116 | } |
| 111 | - |
|
| 112 | 117 | }else { |
| 113 | - header('HTTP/1.0 400 Bad Request'); |
|
| 114 | - echo json_encode(array("failed"=>"Bad Reqest"), JSON_FORCE_OBJECT); |
|
| 118 | + header('HTTP/1.0 401 Unauthorized'); |
|
| 119 | + echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
|
| 115 | 120 | exit; |
| 116 | 121 | } |
| 117 | - }else { |
|
| 118 | - header('HTTP/1.0 401 Unauthorized'); |
|
| 119 | - echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
|
| 120 | - exit; |
|
| 121 | - } |
|
| 122 | - break; |
|
| 123 | - case 'DELETE': |
|
| 124 | - //Here Handle DELETE Request |
|
| 125 | - break; |
|
| 126 | - case 'PUT': |
|
| 127 | - //Here Handle PUT Request |
|
| 128 | - break; |
|
| 129 | - case 'OPTIONS': |
|
| 130 | - //Here Handle OPTIONS/Pre-flight requests |
|
| 131 | - header("Access-Control-Allow-Headers: Accept, Content-Type, Access-Control-Allow-Origin, x-access-token"); |
|
| 132 | - header("Access-Control-Allow-Methods: GET,POST"); |
|
| 133 | - echo(""); |
|
| 134 | - break; |
|
| 122 | + break; |
|
| 123 | + case 'DELETE': |
|
| 124 | + //Here Handle DELETE Request |
|
| 125 | + break; |
|
| 126 | + case 'PUT': |
|
| 127 | + //Here Handle PUT Request |
|
| 128 | + break; |
|
| 129 | + case 'OPTIONS': |
|
| 130 | + //Here Handle OPTIONS/Pre-flight requests |
|
| 131 | + header("Access-Control-Allow-Headers: Accept, Content-Type, Access-Control-Allow-Origin, x-access-token"); |
|
| 132 | + header("Access-Control-Allow-Methods: GET,POST"); |
|
| 133 | + echo(""); |
|
| 134 | + break; |
|
| 135 | 135 | } |
| 136 | 136 | ?> |
| 137 | 137 | \ No newline at end of file |
@@ -51,23 +51,23 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | echo($json); |
| 53 | 53 | |
| 54 | - }else { |
|
| 54 | + } else { |
|
| 55 | 55 | header('HTTP/1.0 401 Unauthorized'); |
| 56 | 56 | echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
| 57 | 57 | exit; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - }else { |
|
| 60 | + } else { |
|
| 61 | 61 | header('HTTP/1.0 401 Unauthorized'); |
| 62 | 62 | echo json_encode(array("failed"=>"No user id provided"), JSON_FORCE_OBJECT); |
| 63 | 63 | exit; |
| 64 | 64 | } |
| 65 | - }else { |
|
| 65 | + } else { |
|
| 66 | 66 | header('HTTP/1.0 401 Unauthorized'); |
| 67 | 67 | echo json_encode(array("failed"=>'Invalid token, please reauthorize user'), JSON_FORCE_OBJECT); |
| 68 | 68 | exit; |
| 69 | 69 | } |
| 70 | - }else { |
|
| 70 | + } else { |
|
| 71 | 71 | header('HTTP/1.0 401 Unauthorized'); |
| 72 | 72 | echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
| 73 | 73 | exit; |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 99 | 99 | |
| 100 | 100 | echo($json); |
| 101 | - }else { |
|
| 101 | + } else { |
|
| 102 | 102 | header('HTTP/1.0 401 Unauthorized'); |
| 103 | 103 | echo json_encode(array("failed"=>"Invalid token"), JSON_FORCE_OBJECT); |
| 104 | 104 | exit; |
| 105 | 105 | } |
| 106 | - }else { |
|
| 106 | + } else { |
|
| 107 | 107 | header('HTTP/1.0 400 Bad Request'); |
| 108 | 108 | echo json_encode(array("failed"=>"Bad Reqest"), JSON_FORCE_OBJECT); |
| 109 | 109 | exit; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - }else { |
|
| 112 | + } else { |
|
| 113 | 113 | header('HTTP/1.0 400 Bad Request'); |
| 114 | 114 | echo json_encode(array("failed"=>"Bad Reqest"), JSON_FORCE_OBJECT); |
| 115 | 115 | exit; |
| 116 | 116 | } |
| 117 | - }else { |
|
| 117 | + } else { |
|
| 118 | 118 | header('HTTP/1.0 401 Unauthorized'); |
| 119 | 119 | echo json_encode(array("failed"=>'No authorization token provided'), JSON_FORCE_OBJECT); |
| 120 | 120 | exit; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $result = JobSeekerController::getJobSeekerProfileByUserId(intval($user_id)); |
| 38 | 38 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 39 | 39 | echo($json); |
| 40 | - }else { |
|
| 40 | + } else { |
|
| 41 | 41 | $result = array(); |
| 42 | 42 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 43 | 43 | echo($json); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | //$json = json_encode($result, JSON_PRETTY_PRINT); |
| 92 | 92 | echo($result); |
| 93 | - }else { |
|
| 93 | + } else { |
|
| 94 | 94 | $result = array(); |
| 95 | 95 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 96 | 96 | echo($json); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 37 | 37 | header("Content-length:" . strlen($json)); |
| 38 | 38 | echo($json); |
| 39 | - }else { |
|
| 39 | + } else { |
|
| 40 | 40 | $result = array(); |
| 41 | 41 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 42 | 42 | echo($json); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 52 | 52 | header("Content-length:" . strlen($json)); |
| 53 | 53 | echo($json); |
| 54 | - }else { |
|
| 54 | + } else { |
|
| 55 | 55 | $result = array(); |
| 56 | 56 | $json = json_encode($result, JSON_PRETTY_PRINT); |
| 57 | 57 | echo($json); |