Test and fix ACL Editor
This commit is contained in:
parent
ae1da5f2b2
commit
5039722d90
2 changed files with 49 additions and 23 deletions
|
@ -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(),
|
||||
|
|
|
@ -21,9 +21,15 @@ class AccessControlState extends State<AccessControlListPage> {
|
|||
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<ACLEdit> {
|
|||
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(
|
||||
|
@ -110,14 +117,22 @@ class ACLEditorState extends State<ACLEdit> {
|
|||
username.text,
|
||||
current!.passwordHash,
|
||||
current!.passwordSalt,
|
||||
current!.permissions));
|
||||
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<ACLEdit> {
|
|||
title: Text("Username"),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
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<ACLEdit> {
|
|||
title: Text("Password"),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
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);
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue