Perbaikan Auth logout
This commit is contained in:
parent
3fa31f6a64
commit
c233f6cef6
@ -121,13 +121,6 @@ class Auth extends Controller {
|
|||||||
// // 'secure' => $isSecure, // true for HTTPS, false for HTTP (localhost)
|
// // 'secure' => $isSecure, // true for HTTPS, false for HTTP (localhost)
|
||||||
// // 'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
// // 'httponly' => true, // dipakai agar cookie berikut tidak dapat diakses oleh javascript
|
||||||
// // 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
// // 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
// 'name' => 'token',
|
|
||||||
// 'value' => '',
|
|
||||||
// 'expire' => time() - 3600,
|
|
||||||
// 'path' => '/',
|
|
||||||
// 'secure' => true,
|
|
||||||
// 'httponly' => true,
|
|
||||||
// 'samesite' => Cookie::SAMESITE_NONE
|
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
|
|
||||||
@ -195,17 +188,34 @@ class Auth extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
|
// public function logout() {
|
||||||
|
// // Definisikan ini pada cookies browser, harus sama dengan cookies login
|
||||||
|
// // $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
||||||
|
// return $this->response->setCookie([
|
||||||
|
// 'name' => 'token',
|
||||||
|
// 'value' => '',
|
||||||
|
// 'expire' => time() - 3600,
|
||||||
|
// 'path' => '/',
|
||||||
|
// 'secure' => $isSecure,
|
||||||
|
// 'httponly' => true,
|
||||||
|
// 'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
||||||
|
|
||||||
|
// ])->setJSON([
|
||||||
|
// 'status' => 'success',
|
||||||
|
// 'code' => 200,
|
||||||
|
// 'message' => 'Logout successful'
|
||||||
|
// ], 200);
|
||||||
|
// }
|
||||||
public function logout() {
|
public function logout() {
|
||||||
// Definisikan ini pada cookies browser, harus sama dengan cookies login
|
// Definisikan ini pada cookies browser, harus sama dengan cookies login
|
||||||
// $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
|
|
||||||
return $this->response->setCookie([
|
return $this->response->setCookie([
|
||||||
'name' => 'token',
|
'name' => 'token',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'expire' => time() - 3600,
|
'expire' => time() - 3600,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'secure' => $isSecure,
|
'secure' => true,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => $isSecure ? Cookie::SAMESITE_NONE : Cookie::SAMESITE_LAX
|
'samesite' => Cookie::SAMESITE_NONE
|
||||||
|
|
||||||
])->setJSON([
|
])->setJSON([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user