Merge branch 'master' of tzw/fcs into master
This commit is contained in:
@@ -133,7 +133,7 @@ class User {
|
||||
}
|
||||
|
||||
bool isCustomer() {
|
||||
return privileges.length == 0;
|
||||
return privileges.isEmpty;
|
||||
}
|
||||
|
||||
bool hasSysAdmin() {
|
||||
@@ -188,6 +188,10 @@ class User {
|
||||
return hasSysAdmin() || hasAdmin() || _has(privilege_carton);
|
||||
}
|
||||
|
||||
bool hasPinLogin() {
|
||||
return _has(privilege_pin);
|
||||
}
|
||||
|
||||
bool _has(String privilege) {
|
||||
return (privileges.contains(privilege));
|
||||
}
|
||||
|
||||
@@ -408,6 +408,17 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
final pinLoginBtn = IconButton(
|
||||
onPressed: () {
|
||||
if (!mainModel.hasPinLogin()) {
|
||||
showMsgDialog(context, "Error", "Login user doesn't have permission");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainModel.allowPin()) {
|
||||
showMsgDialog(
|
||||
context, "Error", "Login user has more than one privilege");
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
|
||||
@@ -82,6 +82,17 @@ class MainModel extends ChangeNotifier {
|
||||
return this.user != null && this.user!.hasAdmin();
|
||||
}
|
||||
|
||||
bool hasPinLogin() {
|
||||
return user != null && user!.hasPinLogin();
|
||||
}
|
||||
|
||||
bool allowPin() {
|
||||
return user != null &&
|
||||
user!.privileges.isNotEmpty &&
|
||||
user!.privileges.length == 1 &&
|
||||
hasPinLogin();
|
||||
}
|
||||
|
||||
// userListener should never be closed
|
||||
StreamSubscription<User?>? userListener;
|
||||
_init() async {
|
||||
|
||||
Reference in New Issue
Block a user