Rip out sessions, they don't work cross domain. Rely on information received previously. Sessions will not extend past the current browser session most likely.
This commit is contained in:
parent
a490412f6b
commit
75de51ec14
7 changed files with 157 additions and 167 deletions
|
@ -92,18 +92,10 @@ class C2SPerformSetupPacket implements IPacket {
|
|||
class S2CPongPacket implements IPacket {
|
||||
final String PSK;
|
||||
final bool authorized;
|
||||
final String user;
|
||||
final String displayName;
|
||||
final bool loggedIn;
|
||||
final int totalUsers;
|
||||
|
||||
S2CPongPacket(
|
||||
{required this.PSK,
|
||||
required this.authorized,
|
||||
required this.user,
|
||||
required this.displayName,
|
||||
required this.loggedIn,
|
||||
required this.totalUsers});
|
||||
{required this.PSK, required this.authorized, required this.totalUsers});
|
||||
|
||||
@override
|
||||
String encode() {
|
||||
|
@ -111,9 +103,6 @@ class S2CPongPacket implements IPacket {
|
|||
"psk": PSK,
|
||||
"authorized": authorized,
|
||||
"type": getType(),
|
||||
"login": loggedIn,
|
||||
"user": user,
|
||||
"display_name": displayName,
|
||||
"user_count": totalUsers
|
||||
});
|
||||
}
|
||||
|
@ -134,9 +123,6 @@ class S2CPongPacket implements IPacket {
|
|||
return S2CPongPacket(
|
||||
PSK: map['psk'] as String,
|
||||
authorized: map['authorized'] as bool,
|
||||
user: map['user'] as String,
|
||||
displayName: map['display_name'] as String,
|
||||
loggedIn: map['login'] as bool,
|
||||
totalUsers: map['user_count'] as int);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
String clientPSK = "";
|
||||
String PSKHash = "";
|
||||
|
||||
bool polling = true;
|
||||
|
||||
@override
|
||||
Future<void> didChangeDependencies() async {
|
||||
var reply = await settings.sendPacketToEndpoint(
|
||||
|
@ -85,7 +87,9 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
}
|
||||
settings.totalGridUsers = pong.totalUsers;
|
||||
|
||||
setState(() {});
|
||||
setState(() {
|
||||
polling = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -105,151 +109,164 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
child: settings.OpenSimSetupCompleted
|
||||
child: polling
|
||||
? Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
"There are ${settings.totalGridUsers} users registered with this grid",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
settings.loggedIn
|
||||
? "Welcome, ${settings.displayName}"
|
||||
: "You are not currently logged in",
|
||||
),
|
||||
),
|
||||
settings.loggedIn
|
||||
? Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
settings.loggedIn = false;
|
||||
settings.currentUser = null;
|
||||
|
||||
await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.Logout, NullPacket());
|
||||
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("LOGOUT"))
|
||||
],
|
||||
)
|
||||
: Center(
|
||||
child: Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context, "/opensim/login");
|
||||
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("Login")),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context, "/opensim/register");
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("Register Account"))
|
||||
],
|
||||
))
|
||||
title: Text("Please wait... downloading content"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
)
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
const ListTile(
|
||||
title: Text("Initial Setup Required"),
|
||||
subtitle: Text(
|
||||
"Please use the same database/user as robust's database\n\nNOTE: Only MySQL/MariaDB is supported by this interface"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Host"),
|
||||
subtitle: TextField(
|
||||
controller: databaseHostController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "example.com:3306"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Username"),
|
||||
subtitle: TextField(
|
||||
controller: databaseUsernameController,
|
||||
decoration:
|
||||
const InputDecoration(hintText: "Username"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Password"),
|
||||
subtitle: TextField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: "****", hintMaxLines: 1),
|
||||
obscureText: true,
|
||||
obscuringCharacter: "*",
|
||||
controller: databasePasswordController,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Name"),
|
||||
subtitle: TextField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: "acwi", hintMaxLines: 1),
|
||||
controller: databaseNameController,
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
title: Text(
|
||||
"For the PreShared Secret, please enter any text you wish. This is hashed 8192 times for the server key. And an additional 16384 times for the client, and any derived key thereafter"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("PreShared Secret"),
|
||||
subtitle: TextField(
|
||||
controller: PSKController,
|
||||
decoration: const InputDecoration(
|
||||
hintText:
|
||||
"Pre-Shared Key. Some text that gets hashed several thousand times to create a server and client key"),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
PSKHash =
|
||||
await settings.hashPSK(PSKController.text);
|
||||
: settings.OpenSimSetupCompleted
|
||||
? Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
"There are ${settings.totalGridUsers} users registered with this grid",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
settings.loggedIn
|
||||
? "Welcome, ${settings.displayName}"
|
||||
: "You are not currently logged in",
|
||||
),
|
||||
),
|
||||
settings.loggedIn
|
||||
? Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
settings.loggedIn = false;
|
||||
settings.currentUser = null;
|
||||
|
||||
clientPSK = await settings.createDerivedPSK(
|
||||
PSKHash, "client");
|
||||
await settings
|
||||
.sendPacketToEndpoint(
|
||||
APIEndpoint.Logout,
|
||||
NullPacket());
|
||||
|
||||
C2SPerformSetupPacket packet =
|
||||
C2SPerformSetupPacket(
|
||||
PSK: PSKHash,
|
||||
ClientPSK: clientPSK,
|
||||
host: databaseHostController.text,
|
||||
user: databaseUsernameController.text,
|
||||
pass: databasePasswordController.text,
|
||||
db: databaseNameController.text);
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("LOGOUT"))
|
||||
],
|
||||
)
|
||||
: Center(
|
||||
child: Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context, "/opensim/login");
|
||||
|
||||
var responsePacket =
|
||||
await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.Setup, packet)
|
||||
as S2CSimpleReplyPacket;
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("Login")),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await Navigator.pushNamed(
|
||||
context, "/opensim/register");
|
||||
didChangeDependencies();
|
||||
},
|
||||
child: Text("Register Account"))
|
||||
],
|
||||
))
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
const ListTile(
|
||||
title: Text("Initial Setup Required"),
|
||||
subtitle: Text(
|
||||
"Please use the same database/user as robust's database\n\nNOTE: Only MySQL/MariaDB is supported by this interface"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Host"),
|
||||
subtitle: TextField(
|
||||
controller: databaseHostController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "example.com:3306"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Username"),
|
||||
subtitle: TextField(
|
||||
controller: databaseUsernameController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Username"),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Password"),
|
||||
subtitle: TextField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: "****", hintMaxLines: 1),
|
||||
obscureText: true,
|
||||
obscuringCharacter: "*",
|
||||
controller: databasePasswordController,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("Database Name"),
|
||||
subtitle: TextField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: "acwi", hintMaxLines: 1),
|
||||
controller: databaseNameController,
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
title: Text(
|
||||
"For the PreShared Secret, please enter any text you wish. This is hashed 8192 times for the server key. And an additional 16384 times for the client, and any derived key thereafter"),
|
||||
tileColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text("PreShared Secret"),
|
||||
subtitle: TextField(
|
||||
controller: PSKController,
|
||||
decoration: const InputDecoration(
|
||||
hintText:
|
||||
"Pre-Shared Key. Some text that gets hashed several thousand times to create a server and client key"),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
PSKHash = await settings
|
||||
.hashPSK(PSKController.text);
|
||||
|
||||
if (responsePacket.done) {
|
||||
settings.OpenSimSetupCompleted = true;
|
||||
} else {
|
||||
settings.OpenSimSetupCompleted = false;
|
||||
}
|
||||
clientPSK = await settings.createDerivedPSK(
|
||||
PSKHash, "client");
|
||||
|
||||
didChangeDependencies();
|
||||
C2SPerformSetupPacket packet =
|
||||
C2SPerformSetupPacket(
|
||||
PSK: PSKHash,
|
||||
ClientPSK: clientPSK,
|
||||
host: databaseHostController.text,
|
||||
user:
|
||||
databaseUsernameController.text,
|
||||
pass:
|
||||
databasePasswordController.text,
|
||||
db: databaseNameController.text);
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: const Text("Submit"))
|
||||
],
|
||||
),
|
||||
var responsePacket =
|
||||
await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.Setup, packet)
|
||||
as S2CSimpleReplyPacket;
|
||||
|
||||
if (responsePacket.done) {
|
||||
settings.OpenSimSetupCompleted = true;
|
||||
} else {
|
||||
settings.OpenSimSetupCompleted = false;
|
||||
}
|
||||
|
||||
didChangeDependencies();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: const Text("Submit"))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -18,9 +18,9 @@ enum InventoryFolder {
|
|||
Outfit(id: 47, name: "Outfit"),
|
||||
MyOutfits(id: 48, name: "My Outfits"),
|
||||
// 49 Mesh
|
||||
//50 Inbox
|
||||
//51 Outbox
|
||||
//52 BasicRoot
|
||||
// 50 Inbox
|
||||
// 51 Outbox
|
||||
// 52 BasicRoot
|
||||
MarketplaceListings(id: 53, name: "Marketplace Listings"),
|
||||
MarketplaceStock(id: 54, name: "Marketplace Stock"),
|
||||
// 55 Marketplace version
|
||||
|
|
|
@ -73,6 +73,4 @@ function gen_uuid()
|
|||
mt_rand(0, 0xffff)
|
||||
);
|
||||
}
|
||||
|
||||
session_start();
|
||||
?>
|
|
@ -34,7 +34,6 @@ if($clientKey == CLIENTPSK) {
|
|||
|
||||
if(md5($password.":" . $pwSalt) == $pwHash) {
|
||||
// Login Success
|
||||
$_SESSION['login'] = "1";
|
||||
$id = $row['UUID'];
|
||||
$first = $row['FirstName'];
|
||||
$last = $row['LastName'];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
if(!defined("COMMON"))
|
||||
require ("Common.php");
|
||||
|
||||
session_destroy();
|
||||
// Edit database?
|
||||
|
||||
die(json_encode(array(
|
||||
"done" => true,
|
||||
|
|
10
php/Ping.php
10
php/Ping.php
|
@ -20,13 +20,6 @@ if(!defined("CLIENTPSK")) {
|
|||
// Authorized. Send the PSK value to the client
|
||||
$allow=true;
|
||||
$psk = PSK;
|
||||
|
||||
// Check session
|
||||
if(isset($_SESSION['login'])) {
|
||||
$logged_in = true;
|
||||
$user = $_SESSION['user'];
|
||||
$display_name = $_SESSION['display_name'];
|
||||
}
|
||||
}else {
|
||||
$allow=false;
|
||||
}
|
||||
|
@ -42,10 +35,7 @@ if(!defined("CLIENTPSK")) {
|
|||
$ret = array(
|
||||
"type" => "S2CPong",
|
||||
"authorized" => $allow,
|
||||
"user" => $user,
|
||||
"display_name" => $display_name,
|
||||
"psk" => $psk,
|
||||
"login" => $logged_in,
|
||||
"user_count" => $totalUsers
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue