Adds a logout button and script

This commit is contained in:
zontreck 2024-05-16 03:52:45 -07:00
parent 0982ffb504
commit a4ec368d4a
5 changed files with 33 additions and 21 deletions

View file

@ -8,7 +8,7 @@ class Constants {
static const DRAWER_COLOR = Color.fromARGB(148, 0, 97, 97); static const DRAWER_COLOR = Color.fromARGB(148, 0, 97, 97);
static const PORTFOLIO_CARD_COLOR = Color.fromARGB(255, 0, 71, 97); static const PORTFOLIO_CARD_COLOR = Color.fromARGB(255, 0, 71, 97);
static const VERSION = "Version 1.0.051624.0201"; static const VERSION = "Version 1.0.051624.0352";
static const COPYRIGHT = "Copyright 2024 - Tara Piccari. All rights Reserved"; static const COPYRIGHT = "Copyright 2024 - Tara Piccari. All rights Reserved";
static const CLIENTPSK = static const CLIENTPSK =
"f5c6caf3efe1ec5aa4b7c572f92aa14782b7be34b4c7844fa9c6d47fdf94246"; "f5c6caf3efe1ec5aa4b7c572f92aa14782b7be34b4c7844fa9c6d47fdf94246";

View file

@ -11,6 +11,7 @@ enum APIEndpoint {
Ping(script: "Ping.php", path: "/ac/home/supports/"), Ping(script: "Ping.php", path: "/ac/home/supports/"),
Setup(script: "Setup.php", path: "/ac/home/supports/"), Setup(script: "Setup.php", path: "/ac/home/supports/"),
Register(script: "Register.php", path: "/ac/home/supports/"), Register(script: "Register.php", path: "/ac/home/supports/"),
Logout(script: "Logout.php", path: "/ac/home/supports/"),
Login(script: "Login.php", path: "/ac/home/supports/"); Login(script: "Login.php", path: "/ac/home/supports/");
final String script; final String script;

View file

@ -113,12 +113,24 @@ class OpenSimPageState extends State<OpenSimPage> {
), ),
), ),
ListTile( ListTile(
title: Text(settings.loggedIn title: Text(
settings.loggedIn
? "Welcome, ${settings.displayName}" ? "Welcome, ${settings.displayName}"
: "You are not currently logged in"), : "You are not currently logged in",
),
), ),
settings.loggedIn settings.loggedIn
? SizedBox() ? Column(
children: [
ElevatedButton(
onPressed: () async {
settings.loggedIn = false;
await settings.sendPacketToEndpoint(
APIEndpoint.Logout, NullPacket());
},
child: Text("LOGOUT"))
],
)
: Center( : Center(
child: Row( child: Row(
children: [ children: [

View file

@ -15,7 +15,7 @@ $password = $js["password"];
$DB = get_DB(); $DB = get_DB();
$id = NULLKEY; $id = NULLKEY;
$rezday = 0; $rez = 0;
$title = ""; $title = "";
$login = false; $login = false;
$reason = "Unauthorized"; $reason = "Unauthorized";
@ -26,19 +26,6 @@ if($clientKey == CLIENTPSK) {
// PSK Matches, authorized application // PSK Matches, authorized application
$res = $DB->query("SELECT * FROM `UserAccounts` INNER JOIN `auth` ON `UserAccounts`.`PrincipalID` = `auth`.`UUID` WHERE `FirstName` = '$first' AND `LastName` = '$last';"); $res = $DB->query("SELECT * FROM `UserAccounts` INNER JOIN `auth` ON `UserAccounts`.`PrincipalID` = `auth`.`UUID` WHERE `FirstName` = '$first' AND `LastName` = '$last';");
/*
*
return User(
ID: UUID.parse(map['id'] as String),
FirstName: map['first'] as String,
LastName: map['last'] as String,
createdAt: map['rezzed'] as int,
userTitle: map['title'] as String);
return S2CLoginResponsePacket(
loggedIn: map['login'] as bool,
reason: map['reason'] as String,
user: User.parseJson(json.encode(map['user'])));
*/
if($res->num_rows > 0) { if($res->num_rows > 0) {
$row = $res->fetch_assoc(); $row = $res->fetch_assoc();
@ -51,7 +38,7 @@ if($clientKey == CLIENTPSK) {
$id = $row['UUID']; $id = $row['UUID'];
$first = $row['FirstName']; $first = $row['FirstName'];
$last = $row['LastName']; $last = $row['LastName'];
$rezday = $row['createdAt']; $rez = (int)$row['createdAt'];
$title = $row['UserTitle']; $title = $row['UserTitle'];
$active = $row['active'] == 1; $active = $row['active'] == 1;
@ -77,7 +64,7 @@ die(json_encode(
"first" => $first, "first" => $first,
"last" => $last, "last" => $last,
"title" => $title, "title" => $title,
"rez" => $rezday, "rez" => $rez,
"active" => $active "active" => $active
) )
) )

12
php/Logout.php Normal file
View file

@ -0,0 +1,12 @@
<?php
if(!defined("COMMON"))
require ("Common.php");
session_destroy();
die(json_encode(array(
"done" => true,
"type" => "S2CSimpleReply"
)));
?>