Now handle logout by invalidating session in database
This commit is contained in:
parent
b99f4c3140
commit
e71f55cbc4
3 changed files with 31 additions and 2 deletions
|
@ -326,6 +326,26 @@ class C2SSessionCheckPacket extends IPacket {
|
|||
}
|
||||
}
|
||||
|
||||
class C2SLogoutPacket extends IPacket {
|
||||
UUID ID;
|
||||
C2SLogoutPacket({required this.ID});
|
||||
|
||||
@override
|
||||
HTTPMethod method() {
|
||||
return HTTPMethod.Post;
|
||||
}
|
||||
|
||||
@override
|
||||
String getType() {
|
||||
return "C2SLogout";
|
||||
}
|
||||
|
||||
@override
|
||||
String encode() {
|
||||
return json.encode({"type": getType(), "id": ID.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
class S2CSessionCheckPacket extends IPacket {
|
||||
String id;
|
||||
final bool valid;
|
||||
|
|
|
@ -202,7 +202,10 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
await settings
|
||||
.sendPacketToEndpoint(
|
||||
APIEndpoint.Logout,
|
||||
NullPacket());
|
||||
C2SLogoutPacket(
|
||||
ID: settings
|
||||
.currentUser!
|
||||
.loginToken));
|
||||
|
||||
SharedPreferences prefs =
|
||||
await SharedPreferences
|
||||
|
|
|
@ -2,7 +2,13 @@
|
|||
if(!defined("COMMON"))
|
||||
require ("Common.php");
|
||||
|
||||
// Edit database?
|
||||
|
||||
// Edit database
|
||||
$js = getJsonizedInput();
|
||||
$token = $js['id'];
|
||||
|
||||
$DB = get_DB();
|
||||
$res = $DB->query("UPDATE `auth` SET `webLoginKey` = '".NULLKEY."' WHERE `webLoginKey` = '".$token."';");
|
||||
|
||||
die(json_encode(array(
|
||||
"done" => true,
|
||||
|
|
Loading…
Reference in a new issue