feat: Logout jarak jauh wali — cabut semua token Sanctum dari panel admin, app langsung 401 → login ulang
This commit is contained in:
@@ -47,6 +47,20 @@ class WaliMuridController extends Controller
|
||||
return view('parents.index', compact('users', 'total', 'totalAktif', 'pending', 'baruMingguIni'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout jarak jauh: cabut semua token Sanctum akun wali
|
||||
* → app di semua perangkat langsung 401 → otomatis kembali ke login.
|
||||
*/
|
||||
public function forceLogout(int $userId): RedirectResponse
|
||||
{
|
||||
$user = User::where('role', 'parent')->findOrFail($userId);
|
||||
|
||||
$user->tokens()->delete();
|
||||
$user->forceFill(['active_session_token' => null])->save();
|
||||
|
||||
return back()->with('success', 'Semua perangkat akun "' . $user->name . '" telah di-logout dari jarak jauh.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hapus akun wali murid beserta tautan anak & perangkatnya.
|
||||
* Hanya akun role=parent yang boleh dihapus lewat sini.
|
||||
|
||||
Reference in New Issue
Block a user