feat: Enhance user permissions handling when no users on server

This commit is contained in:
2024-12-25 07:21:37 +00:00
committed by GitHub
parent 69c52ee8d6
commit 93b8cc86a5
5 changed files with 29 additions and 19 deletions

View File

@@ -92,6 +92,9 @@ class _NewUserPage extends State<NewUserPage> {
}
final i18n = AppLocalizations.of(context)!;
final maxWidth = MediaQuery.of(context).size.width;
if (auth.noUser == true) {
_isAdmin = true;
}
return Container(
padding: maxWidth < 400
? const EdgeInsets.symmetric(vertical: 20, horizontal: 5)
@@ -159,16 +162,18 @@ class _NewUserPage extends State<NewUserPage> {
},
obscureText: !_passwordVisible,
)),
auth.isRoot == true
auth.isRoot == true || auth.noUser == true
? _buildWithVecticalPadding(LabeledCheckbox(
value: _isAdmin,
onChanged: (b) {
if (b != null) {
setState(() {
_isAdmin = b;
});
}
},
onChanged: auth.noUser == true
? null
: (b) {
if (b != null) {
setState(() {
_isAdmin = b;
});
}
},
label: Text(i18n.admin)))
: Container(),
!_isAdmin