Testing JWT Untuk Routes tertentu
This commit is contained in:
parent
2af6fb474f
commit
6ae72a6bb1
@ -71,7 +71,7 @@ class Filters extends BaseFilters
|
|||||||
*/
|
*/
|
||||||
public array $globals = [
|
public array $globals = [
|
||||||
'before' => [
|
'before' => [
|
||||||
// 'auth',
|
'auth',
|
||||||
'cors',
|
'cors',
|
||||||
// 'honeypot',
|
// 'honeypot',
|
||||||
// 'csrf',
|
// 'csrf',
|
||||||
|
|||||||
@ -16,15 +16,15 @@ $routes->post('/api/v1/emr/lab/insert', 'NUHATEMP::create');
|
|||||||
$routes->post('/api/v1/emr/lab/update-validasi', 'NUHATEMP::update');
|
$routes->post('/api/v1/emr/lab/update-validasi', 'NUHATEMP::update');
|
||||||
$routes->post('/api/v1/emr/lab/detail', 'NUHATEMP::detail');
|
$routes->post('/api/v1/emr/lab/detail', 'NUHATEMP::detail');
|
||||||
|
|
||||||
// $routes->group('api', ['filter' => 'auth'], function($routes) {
|
$routes->group('api', ['filter' => 'auth'], function($routes) {
|
||||||
$routes->post('/api/coba-auth', 'Auth::coba');
|
$routes->get('coba-auth', 'Auth::coba');
|
||||||
|
});
|
||||||
$routes->post('/api/auth/login', 'Auth::login');
|
$routes->post('/api/auth/login', 'Auth::login');
|
||||||
$routes->post('/api/auth/change_pass', 'Auth::change_pass');
|
$routes->post('/api/auth/change_pass', 'Auth::change_pass');
|
||||||
$routes->post('/api/auth/register', 'Auth::register');
|
$routes->post('/api/auth/register', 'Auth::register');
|
||||||
$routes->get('/api/auth/check', 'Auth::checkAuth');
|
$routes->get('/api/auth/check', 'Auth::checkAuth');
|
||||||
$routes->post('/api/auth/logout', 'Auth::logout');
|
$routes->post('/api/auth/logout', 'Auth::logout');
|
||||||
// });
|
|
||||||
|
|
||||||
$routes->get('/api/patient', 'Patient::index');
|
$routes->get('/api/patient', 'Patient::index');
|
||||||
$routes->post('/api/patient', 'Patient::create');
|
$routes->post('/api/patient', 'Patient::create');
|
||||||
|
|||||||
@ -208,10 +208,23 @@ class Auth extends Controller {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
public function coba() {
|
public function coba() {
|
||||||
|
|
||||||
|
$token = $this->request->getCookie('token');
|
||||||
|
$key = getenv('JWT_SECRET');
|
||||||
|
|
||||||
|
// Decode Token dengan Key yg ada di .env
|
||||||
|
$decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Already Login'
|
'message' => 'Authenticated',
|
||||||
],200);
|
'data' => $decodedPayload
|
||||||
|
], 200);
|
||||||
|
|
||||||
|
// return $this->respond([
|
||||||
|
// 'status' => 'success',
|
||||||
|
// 'message' => 'Already Login'
|
||||||
|
// ],200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user