Readd permission checks respecting *
This commit is contained in:
parent
23a6739eb1
commit
68f6f5ea79
@ -574,12 +574,27 @@ public final class User {
|
||||
if (error != null) {
|
||||
callback.onResult(null, error);
|
||||
} else {
|
||||
boolean hasPermission = permissions.containsKey(permission) && permissions.get(permission);
|
||||
boolean hasPermission = hasPermission(permission, permissions);
|
||||
callback.onResult(hasPermission, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean hasPermission(String permission, Map<String, Boolean> permissions) {
|
||||
if (permissions.containsKey(permission) && permissions.get(permission)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int lastDot = permission.lastIndexOf(".");
|
||||
|
||||
if (lastDot == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String modifiedPermission = permission.substring(0, lastDot) + ".*";
|
||||
return permissions.containsKey(modifiedPermission) && permissions.get(modifiedPermission);
|
||||
}
|
||||
|
||||
public void getCompoundedPermissions(SingleResultCallback<Map<String, Boolean>> callback) {
|
||||
Grant.findByUser(this, (grants, error) -> {
|
||||
if (error != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user