0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

fix logging in utils/allow_action (#3147)

This commit is contained in:
Dmitry Afanasiev 2022-05-01 17:12:46 +03:00 committed by GitHub
parent f8a7fc94a8
commit e9d1e82666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,17 +188,17 @@ export function allow_action(action: ActionsAllowed, logger): AllowAction {
pkg: AuthPackageAllow, pkg: AuthPackageAllow,
callback: AllowActionCallback callback: AllowActionCallback
): void { ): void {
logger.trace({ remote: user.name }, `[auth/allow_action]: user: @{user.name}`); logger.trace({ remote: user.name }, `[auth/allow_action]: user: @{remote}`);
const { name, groups } = user; const { name, groups } = user;
const groupAccess = pkg[action] as string[]; const groupAccess = pkg[action] as string[];
const hasPermission = groupAccess.some((group) => name === group || groups.includes(group)); const hasPermission = groupAccess.some((group) => name === group || groups.includes(group));
logger.trace( logger.trace(
{ pkgName: pkg.name, hasPermission, remote: user.name, groupAccess }, { pkgName: pkg.name, hasPermission, remote: user.name, groupAccess },
`[auth/allow_action]: hasPermission? @{hasPermission} for user: @{user}` `[auth/allow_action]: hasPermission? @{hasPermission} for user: @{remote}, package: @{pkgName}`
); );
if (hasPermission) { if (hasPermission) {
logger.trace({ remote: user.name }, `auth/allow_action: access granted to: @{user}`); logger.trace({ remote: user.name }, `auth/allow_action: access granted to: @{remote}`);
return callback(null, true); return callback(null, true);
} }