Add PHP Script to activate account
This commit is contained in:
parent
e86ec4dfb1
commit
579939a5f8
6 changed files with 102 additions and 9 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue