mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
Use LOGIN_PERMISSIONS_* to compile permissions directly instead of creating logins. Accept req.user.login in hasPermission
This commit is contained in:
parent
cb9921918f
commit
4214b4f613
@ -9,7 +9,8 @@ function hasPermission(tested, req) {
|
||||
return true;
|
||||
}
|
||||
const { user } = (req && req.auth) || {};
|
||||
const key = user || '';
|
||||
const { login } = (process.env.OAUTH_PERMISSIONS && req && req.user) || {};
|
||||
const key = user || login || '';
|
||||
const logins = getLogins();
|
||||
|
||||
if (!userPermissions[key]) {
|
||||
@ -58,11 +59,7 @@ function getLogins() {
|
||||
for (const permissions_key of login_permission_keys) {
|
||||
const login = permissions_key.replace('LOGIN_PERMISSIONS_', '');
|
||||
const permissions = process.env[permissions_key];
|
||||
res.push({
|
||||
login,
|
||||
password: null,
|
||||
permissions,
|
||||
})
|
||||
userPermissions[login] = compilePermissions(permissions);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user