Skip to content

Commit

Permalink
chore: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpicado committed Nov 5, 2019
1 parent 87c679d commit 6085b6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/authcache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AuthCache {
}

findUser(username: string, password: string): UserData {
return this.storage.get(AuthCache._generateKeyHash(username, password));
return this.storage.get(AuthCache._generateKeyHash(username, password)) as UserData;
}

storeUser(username: string, password: string, userData: UserData): boolean {
Expand Down
7 changes: 6 additions & 1 deletion src/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface VerdaccioGitLabPlugin extends IPluginAuth<VerdaccioGitlabConfig
export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
options: PluginOptions<VerdaccioGitlabConfig>;
config: VerdaccioGitlabConfig;
// @ts-ignore
authCache: AuthCache;
logger: Logger;
publishLevel: VerdaccioGitlabAccessLevel;
Expand Down Expand Up @@ -93,6 +94,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
// Try to find the user groups in the cache
const cachedUserGroups = this._getCachedUserGroups(user, password);
if (cachedUserGroups) {
// @ts-ignore
this.logger.debug(`[gitlab] user: ${user} found in cache, authenticated with groups:`, cachedUserGroups);
return cb(null, cachedUserGroups.publish);
}
Expand Down Expand Up @@ -120,6 +122,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
// - for access, depending on the package settings in verdaccio
// - for publish, the logged in user id and all the groups they can reach as fixed `$auth.gitlab.publish` = `$owner`
const gitlabPublishQueryParams = this.config.legacy_mode ? { owned: true } : { min_access_level: publishLevelId };
// @ts-ignore
this.logger.trace('[gitlab] querying gitlab user groups with params:', gitlabPublishQueryParams);

const groupsPromise = GitlabAPI.Groups.all(gitlabPublishQueryParams).then(groups => {
Expand All @@ -135,6 +138,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
this._setCachedUserGroups(user, password, { publish: realGroups });

this.logger.info(`[gitlab] user: ${user} successfully authenticated`);
// @ts-ignore
this.logger.debug(`[gitlab] user: ${user}, with groups:`, realGroups);

return cb(null, realGroups);
Expand Down Expand Up @@ -201,7 +205,8 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
return cb(null, true);
} else {
this.logger.debug(`[gitlab] user: ${user.name || ''} denied from publishing package: ${_package.name}`);
const missingPerm = _package.name ?? _package.name.indexOf('@') === 0 ? 'package-scope' : 'package-name';
// @ts-ignore
const missingPerm = _package.name.indexOf('@') === 0 ? 'package-scope' : 'package-name';
return cb(getForbidden(`must have required permissions: ${this.publishLevel || ''} at ${missingPerm}`));
}
}
Expand Down

0 comments on commit 6085b6f

Please sign in to comment.