diff --git a/lib/main.dart b/lib/main.dart index 6504f64..c871efd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,6 +32,7 @@ class MyApp extends StatelessWidget { "/home": (context) => HomePage(settings: appSettings), "/creds": (context) => CredentialsPage(), "/acl": (context) => AccessControlListPage(), + "/acl/edit": (context) => ACLEdit(), "/server": (context) => GameServerPage(settings: appSettings), "/server/autorestart": (context) => AutoRestartPage(), "/server/ports": (context) => ServerSettingsPage(), diff --git a/lib/pages/ACL.dart b/lib/pages/ACL.dart index e8fdfca..9d80887 100644 --- a/lib/pages/ACL.dart +++ b/lib/pages/ACL.dart @@ -21,9 +21,15 @@ class AccessControlState extends State { backgroundColor: Constants.TITLEBAR_COLOR, ), floatingActionButton: ElevatedButton( - onPressed: () { + onPressed: () async { // Show the add new user page - Navigator.pushNamed(context, "/acl/edit"); + var reply = await Navigator.pushNamed(context, "/acl/edit"); + if (reply == null) return; + if (reply is User) { + setState(() { + settings.inst!.admins.add(reply as User); + }); + } }, child: Icon(Icons.add), ), @@ -93,7 +99,8 @@ class ACLEditorState extends State { return Scaffold( appBar: AppBar( title: Text( - "CE SM - ACL Edit - ${newUser ? "Create A User" : "Edit User - ${username.text}"}"), + "CE SM - ACL Edit - ${newUser ? "Create A User" : "Edit User - ${username.text}"}", + ), backgroundColor: Constants.TITLEBAR_COLOR, ), floatingActionButton: ElevatedButton( @@ -102,22 +109,30 @@ class ACLEditorState extends State { if (!newUser) { if (password.text.isEmpty) { user = User( - name: username.text, - passwordHash: current!.passwordHash, - passwordSalt: current!.passwordSalt, - permissions: current!.permissions, - userHash: User.generateValidityCode( - username.text, - current!.passwordHash, - current!.passwordSalt, - current!.permissions)); + name: username.text, + passwordHash: current!.passwordHash, + passwordSalt: current!.passwordSalt, + permissions: current!.permissions, + userHash: User.generateValidityCode( + username.text, + current!.passwordHash, + current!.passwordSalt, + current!.permissions, + ), + ); } else { user = User.make( - username.text, password.text, UserLevel.Administrator); + username.text, + password.text, + UserLevel.Administrator, + ); } } else { user = User.make( - username.text, password.text, UserLevel.Administrator); + username.text, + password.text, + UserLevel.Administrator, + ); } Navigator.pop(context, user); @@ -137,16 +152,20 @@ class ACLEditorState extends State { title: Text("Username"), ), ), - TextField( - controller: username, - ) + Expanded( + child: TextField( + controller: username, + ), + ), ], ), if (!newUser) ListTile( title: Text("Warning"), subtitle: Text( - "The password is encrypted, if you wish to change the password do so below, but the field is intentionally not filled in. If left blank, it will remain unchanged."), + "The password is encrypted, if you wish to change the password do so below, but the field is intentionally not filled in. If left blank, it will remain unchanged.", + ), + tileColor: Constants.TITLEBAR_COLOR, ), Row( children: [ @@ -156,21 +175,27 @@ class ACLEditorState extends State { title: Text("Password"), ), ), - TextField( - controller: password, - obscureText: true, - ) + Expanded( + child: TextField( + controller: password, + obscureText: true, + ), + ), ], ), + SizedBox( + height: 50, + ), if (!newUser) ListTile( title: Text("DELETE USER"), leading: Icon(Icons.delete), + tileColor: Constants.TITLEBAR_COLOR, subtitle: Text("Delete the current user entirely"), onTap: () { Navigator.pop(context, false); }, - ) + ), ], ), ),