Skip to content

Commit 2ad82bc

Browse files
Merge pull request #42 from ercanucan/style/whitespace
style(gitlab): consistent white-space usage
2 parents ac6ccd0 + eea4c9e commit 2ad82bc

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/gitlab.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,50 +46,41 @@ export default class VerdaccioGitLab implements IPluginAuth {
4646
logger: Logger;
4747
publishLevel: VerdaccioGitlabAccessLevel;
4848

49-
constructor(
50-
config: VerdaccioGitlabConfig,
51-
options: PluginOptions
52-
) {
49+
constructor(config: VerdaccioGitlabConfig, options: PluginOptions) {
5350
this.logger = options.logger;
54-
5551
this.config = config;
5652
this.options = options;
57-
5853
this.logger.info(`[gitlab] url: ${this.config.url}`);
5954

6055
if ((this.config.authCache || {}).enabled === false) {
6156
this.logger.info('[gitlab] auth cache disabled');
6257
} else {
6358
const ttl = (this.config.authCache || {}).ttl || AuthCache.DEFAULT_TTL;
6459
this.authCache = new AuthCache(this.logger, ttl);
65-
6660
this.logger.info(`[gitlab] initialized auth cache with ttl: ${ttl} seconds`);
6761
}
6862

6963
if (this.config.legacy_mode) {
7064
this.publishLevel = '$owner';
71-
7265
this.logger.info('[gitlab] legacy mode active pre-gitlab v11.2 active, publish is only allowed to group owners');
7366
} else {
7467
this.publishLevel = '$maintainer';
7568
if (this.config.publish) {
7669
this.publishLevel = this.config.publish;
7770
}
7871

79-
if (! Object.keys(ACCESS_LEVEL_MAPPING).includes(this.publishLevel)) {
72+
if (!Object.keys(ACCESS_LEVEL_MAPPING).includes(this.publishLevel)) {
8073
throw Error(`[gitlab] invalid publish access level configuration: ${this.publishLevel}`);
8174
}
8275
this.logger.info(`[gitlab] publish control level: ${this.publishLevel}`);
8376
}
84-
8577
}
8678

8779
authenticate(user: string, password: string, cb: Callback) {
8880
this.logger.trace(`[gitlab] authenticate called for user: ${user}`);
8981

9082
// Try to find the user groups in the cache
9183
const cachedUserGroups = this._getCachedUserGroups(user, password);
92-
9384
if (cachedUserGroups) {
9485
this.logger.debug(`[gitlab] user: ${user} found in cache, authenticated with groups:`, cachedUserGroups);
9586
return cb(null, cachedUserGroups.publish);
@@ -121,11 +112,9 @@ export default class VerdaccioGitLab implements IPluginAuth {
121112
// In legacy mode, the groups are:
122113
// - for access, themselves and all groups with access level $owner
123114
// - for publish, the logged in user id and all the groups they can reach as `$owner`
124-
125115
const gitlabPublishQueryParams = this.config.legacy_mode ? { owned: true } : { min_access_level: publishLevelId };
126116
const pPublishGroups = GitlabAPI.Groups.all(gitlabPublishQueryParams).then(groups => {
127117
this.logger.trace('[gitlab] querying gitlab user groups with params:', gitlabPublishQueryParams);
128-
129118
this._addGroupsToArray(groups, userGroups.publish);
130119
}).catch(error => {
131120
this.logger.error(`[gitlab] user: ${user} error querying publish groups: ${error}`);
@@ -135,15 +124,13 @@ export default class VerdaccioGitLab implements IPluginAuth {
135124
const pGroups = Promise.all([pPublishGroups]);
136125
return pGroups.then(() => {
137126
this._setCachedUserGroups(user, password, userGroups);
138-
139127
this.logger.info(`[gitlab] user: ${user} successfully authenticated`);
140128
this.logger.debug(`[gitlab] user: ${user}, with groups:`, userGroups);
141129
return cb(null, userGroups.publish);
142130
}).catch(error => {
143131
this.logger.error(`[gitlab] error authenticating: ${error}`);
144132
return cb(httperror[500]('error authenticating'));
145133
});
146-
147134
}).catch(error => {
148135
this.logger.info(`[gitlab] user: ${user} error authenticating: ${error.message || {}}`);
149136
if (error) {
@@ -202,15 +189,15 @@ export default class VerdaccioGitLab implements IPluginAuth {
202189
}
203190

204191
_getCachedUserGroups(username: string, password: string): ?UserDataGroups {
205-
if (! this.authCache) {
192+
if (!this.authCache) {
206193
return null;
207194
}
208195
const userData = this.authCache.findUser(username, password);
209196
return (userData || {}).groups || null;
210197
}
211198

212199
_setCachedUserGroups(username: string, password: string, groups: UserDataGroups): boolean {
213-
if (! this.authCache) {
200+
if (!this.authCache) {
214201
return false;
215202
}
216203
this.logger.debug(`[gitlab] saving data in cache for user: ${username}`);

0 commit comments

Comments
 (0)