Final commit for the night. Got logins to work

This commit is contained in:
zontreck 2024-05-16 04:10:25 -07:00
parent a4ec368d4a
commit a490412f6b
3 changed files with 18 additions and 9 deletions

View file

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

View file

@ -68,7 +68,7 @@ class Settings {
String displayName = "";
int totalGridUsers = 0;
late User currentUser;
User? currentUser;
bool get hasUsers => totalGridUsers != 0;
bool get hasNoUsers => totalGridUsers == 0;

View file

@ -78,9 +78,11 @@ class OpenSimPageState extends State<OpenSimPage> {
var pong = await settings.sendPacketToEndpoint(
APIEndpoint.Ping, NullPacket()) as S2CPongPacket;
settings.loggedIn = pong.loggedIn;
settings.userName = pong.user;
settings.displayName = pong.displayName;
if (settings.currentUser != null) {
settings.userName =
"${settings.currentUser!.FirstName}.${settings.currentUser!.LastName}";
settings.displayName = settings.userName;
}
settings.totalGridUsers = pong.totalUsers;
setState(() {});
@ -125,8 +127,12 @@ class OpenSimPageState extends State<OpenSimPage> {
ElevatedButton(
onPressed: () async {
settings.loggedIn = false;
settings.currentUser = null;
await settings.sendPacketToEndpoint(
APIEndpoint.Logout, NullPacket());
didChangeDependencies();
},
child: Text("LOGOUT"))
],
@ -135,15 +141,18 @@ class OpenSimPageState extends State<OpenSimPage> {
child: Row(
children: [
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
onPressed: () async {
await Navigator.pushNamed(
context, "/opensim/login");
didChangeDependencies();
},
child: Text("Login")),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
onPressed: () async {
await Navigator.pushNamed(
context, "/opensim/register");
didChangeDependencies();
},
child: Text("Register Account"))
],