Add PHP Script to activate account
This commit is contained in:
parent
e86ec4dfb1
commit
579939a5f8
6 changed files with 102 additions and 9 deletions
|
@ -13,6 +13,7 @@ class Constants {
|
|||
static const CLIENTPSK =
|
||||
"f5c6caf3efe1ec5aa4b7c572f92aa14782b7be34b4c7844fa9c6d47fdf94246";
|
||||
|
||||
static const DEBUG = true;
|
||||
static const SERVICES_JSON =
|
||||
"https://raw.githubusercontent.com/AriasCreations/AriasCreations/main/services.json";
|
||||
|
||||
|
|
|
@ -426,3 +426,28 @@ class C2SCreateFolderPacket extends IPacket {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
class C2SActivateUserPacket implements IPacket {
|
||||
UUID ID;
|
||||
|
||||
C2SActivateUserPacket({required this.ID});
|
||||
|
||||
@override
|
||||
HTTPMethod method() {
|
||||
return HTTPMethod.Post;
|
||||
}
|
||||
|
||||
@override
|
||||
String getType() {
|
||||
return "C2SActivateUser";
|
||||
}
|
||||
|
||||
@override
|
||||
String encode() {
|
||||
return json.encode({
|
||||
"id": ID.toString(),
|
||||
"client": Hashing.md5Hash(Constants.CLIENTPSK),
|
||||
"type": getType()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ enum APIEndpoint {
|
|||
Logout(script: "Logout.php", path: "/ac/home/supports/"),
|
||||
Login(script: "Login.php", path: "/ac/home/supports/"),
|
||||
ValidateSession(script: "ValidateToken.php", path: "/ac/home/supports/"),
|
||||
MakeFolder(script: "MakeFolder.php", path: "/ac/home/supports/");
|
||||
MakeFolder(script: "MakeFolder.php", path: "/ac/home/supports/"),
|
||||
ActivateUser(script: "ActivateUser.php", path: "/ac/home/supports/");
|
||||
|
||||
final String script;
|
||||
final String path;
|
||||
|
|
|
@ -100,6 +100,7 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
String PSKHash = "";
|
||||
|
||||
bool polling = true;
|
||||
bool activating = false;
|
||||
|
||||
@override
|
||||
Future<void> didChangeDependencies() async {
|
||||
|
@ -151,7 +152,8 @@ class OpenSimPageState extends State<OpenSimPage> {
|
|||
polling = false;
|
||||
});
|
||||
|
||||
if (settings.loggedIn && !settings.currentUser!.active) {
|
||||
if (settings.loggedIn && !settings.currentUser!.active && !activating) {
|
||||
activating = true;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (B) {
|
||||
|
|
|
@ -54,12 +54,40 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
|
|||
|
||||
int value = 0;
|
||||
int total = 100;
|
||||
String status = "";
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
startProcessing();
|
||||
}
|
||||
|
||||
Future<void> enableUserAccount() async {
|
||||
setState(() {
|
||||
status = "Enabling user account";
|
||||
});
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
|
||||
Settings settings = Settings();
|
||||
C2SActivateUserPacket activate =
|
||||
C2SActivateUserPacket(ID: settings.currentUser!.ID);
|
||||
var reply = await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.ActivateUser, activate) as S2CSimpleReplyPacket;
|
||||
if (reply.done) {
|
||||
setState(() {
|
||||
status = "Account Activated";
|
||||
});
|
||||
}
|
||||
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
|
||||
Navigator.pop(context);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"Inventory successfully created. Your account is now active")));
|
||||
}
|
||||
|
||||
bool processing = false;
|
||||
Future<void> startProcessing() async {
|
||||
total = InventoryFolder.values.length;
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
|
@ -68,16 +96,14 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
|
|||
|
||||
Settings settings = Settings();
|
||||
Future<void> createFolder(Timer timer) async {
|
||||
if (processing) return;
|
||||
if (getProgress() >= 1) {
|
||||
timer.cancel();
|
||||
Navigator.pop(context);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"Inventory successfully created. Your account is now active")));
|
||||
enableUserAccount();
|
||||
return;
|
||||
}
|
||||
|
||||
processing = true;
|
||||
UUID parent = rootFolder;
|
||||
UUID id = UUID.generate(4);
|
||||
UUID owner = settings.currentUser!.ID;
|
||||
|
@ -97,6 +123,11 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
|
|||
Owner: owner,
|
||||
client: Constants.CLIENTPSK);
|
||||
|
||||
setState(() {
|
||||
status = ("Creating Inventory Folder: ${name}");
|
||||
if (Constants.DEBUG) print("Creating Inventory Folder: ${name}");
|
||||
});
|
||||
|
||||
var reply = await settings.sendPacketToEndpoint(
|
||||
APIEndpoint.MakeFolder, makeFolder) as S2CSimpleReplyPacket;
|
||||
if (!reply.done) {
|
||||
|
@ -111,11 +142,17 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
|
|||
"For an unknown reason, we failed to create the inventory folders. Some may have been created, but there was an error while processing: ${makeFolder.encodeSafe()}"),
|
||||
);
|
||||
});
|
||||
}
|
||||
} else
|
||||
setState(() {
|
||||
status = ("Created Inventory Folder : ${name}");
|
||||
if (Constants.DEBUG) print("Created Inventory Folder: ${name}");
|
||||
});
|
||||
|
||||
value++;
|
||||
|
||||
setState(() {});
|
||||
setState(() {
|
||||
processing = false;
|
||||
});
|
||||
}
|
||||
|
||||
Timer.periodic(Duration(milliseconds: 500), createFolder);
|
||||
|
@ -131,6 +168,9 @@ class CreateInventoryState extends State<CreateInventoryPopup> {
|
|||
child: Column(
|
||||
children: [
|
||||
Text("Creating necessary Inventory Folders"),
|
||||
Text(
|
||||
status,
|
||||
),
|
||||
Divider(),
|
||||
LinearProgressIndicator(
|
||||
value: getProgress(),
|
||||
|
|
24
php/ActivateUser.php
Normal file
24
php/ActivateUser.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
if(!defined("COMMON"))
|
||||
require("Common.php");
|
||||
|
||||
$js = getJsonizedInput();
|
||||
$DB = get_DB();
|
||||
|
||||
$clientKey = $js['client'];
|
||||
$id = $js['id'];
|
||||
|
||||
$complete=false;
|
||||
if($clientKey == md5(CLIENTPSK)) {
|
||||
$complete=true;
|
||||
$res = $DB->query("UPDATE `UserAccounts` SET `active`=1 WHERE `PrincipalID` = '$id';");
|
||||
}
|
||||
|
||||
|
||||
die(json_encode(array(
|
||||
"done" => $complete,
|
||||
"type" => "S2CSimpleReply"
|
||||
)));
|
||||
|
||||
?>
|
Loading…
Reference in a new issue