Skip to content

Commit

Permalink
Fix paramName to accessTokenParam
Browse files Browse the repository at this point in the history
  • Loading branch information
knrt10 committed Apr 13, 2019
1 parent 83ce203 commit 3b010ff
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions app/custom-oauth/server/custom_oauth_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class CustomOAuth {
Accounts.oauth.registerService(this.name);
this.registerService();
this.addHookToProcessUser();
this.registerAccessTokenService(this.name, this.paramName);
this.registerAccessTokenService(this.name, this.accessTokenParam);
}

configure(options) {
Expand All @@ -61,8 +61,8 @@ export class CustomOAuth {
options.identityPath = '/me';
}

if (!Match.test(options.paramName, String)) {
options.paramName = 'access_token';
if (!Match.test(options.accessTokenParam, String)) {
options.accessTokenParam = 'access_token';
}

this.serverURL = options.serverURL;
Expand All @@ -72,7 +72,7 @@ export class CustomOAuth {
this.identityTokenSentVia = options.identityTokenSentVia;
this.usernameField = (options.usernameField || '').trim();
this.mergeUsers = options.mergeUsers;
this.paramName = options.paramName;
this.accessTokenParam = options.accessTokenParam;

if (this.identityTokenSentVia == null || this.identityTokenSentVia === 'default') {
this.identityTokenSentVia = this.tokenSentVia;
Expand Down Expand Up @@ -141,7 +141,7 @@ export class CustomOAuth {
}
}

getIdentity(accessToken, paramName) {
getIdentity(accessToken, accessTokenParam) {
const params = {};
const headers = {
'User-Agent': this.userAgent, // http://doc.gitlab.com/ce/api/users.html#Current-user
Expand All @@ -150,7 +150,7 @@ export class CustomOAuth {
if (this.identityTokenSentVia === 'header') {
headers.Authorization = `Bearer ${ accessToken }`;
} else {
params[paramName] = accessToken;
params[accessTokenParam] = accessToken;
}

try {
Expand Down Expand Up @@ -181,7 +181,7 @@ export class CustomOAuth {
OAuth.registerService(this.name, 2, null, (query) => {
const accessToken = self.getAccessToken(query);

let identity = self.getIdentity(accessToken, this.paramName);
const identity = self.getIdentity(accessToken, this.accessTokenParam);

const serviceData = {
_OAuthCustom: true,
Expand Down Expand Up @@ -354,7 +354,7 @@ export class CustomOAuth {

}

registerAccessTokenService(name, paramName) {
registerAccessTokenService(name, accessTokenParam) {
const self = this;
const whitelisted = [
'id',
Expand All @@ -369,7 +369,7 @@ export class CustomOAuth {
identity: Match.Maybe(Object),
}));

const identity = options.identity || self.getIdentity(options.accessToken, paramName);
const identity = options.identity || self.getIdentity(options.accessToken, accessTokenParam);

const serviceData = {
accessToken: options.accessToken,
Expand Down
2 changes: 1 addition & 1 deletion app/dolphin/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
forLoggedInUser: ['services.dolphin'],
forOtherUsers: ['services.dolphin.name'],
},
paramName: 'access_token',
accessTokenParam: 'access_token',
};

const Dolphin = new CustomOAuth('dolphin', config);
Expand Down
2 changes: 1 addition & 1 deletion app/drupal/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config = {
forLoggedInUser: ['services.drupal'],
forOtherUsers: ['services.drupal.name'],
},
paramName: 'access_token',
accessTokenParam: 'access_token',
};

const Drupal = new CustomOAuth('drupal', config);
Expand Down
2 changes: 1 addition & 1 deletion app/gitlab/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const config = {
forLoggedInUser: ['services.gitlab'],
forOtherUsers: ['services.gitlab.username'],
},
paramName: 'private_token',
accessTokenParam: 'private_token',
};

const Gitlab = new CustomOAuth('gitlab', config);
Expand Down
4 changes: 2 additions & 2 deletions app/lib/server/methods/addOAuthService.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/lib/server/methods/removeOAuthService.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Meteor.methods({
settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_path`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-authorize_path`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-scope`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-param_name`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-access_token_param`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-token_sent_via`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_token_sent_via`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-id`);
Expand Down
4 changes: 2 additions & 2 deletions app/lib/server/startup/oAuthServicesUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function _OAuthServicesUpdate() {
data.identityPath = settings.get(`${ service.key }-identity_path`);
data.authorizePath = settings.get(`${ service.key }-authorize_path`);
data.scope = settings.get(`${ service.key }-scope`);
data.paramName = settings.get(`${ service.key }-param_name`);
data.accessTokenParam = settings.get(`${ service.key }-access_token_param`);
data.buttonLabelText = settings.get(`${ service.key }-button_label_text`);
data.buttonLabelColor = settings.get(`${ service.key }-button_label_color`);
data.loginStyle = settings.get(`${ service.key }-login_style`);
Expand All @@ -58,7 +58,7 @@ function _OAuthServicesUpdate() {
identityTokenSentVia: data.identityTokenSentVia,
usernameField: data.usernameField,
mergeUsers: data.mergeUsers,
paramName: data.paramName,
accessTokenParam: data.accessTokenParam,
});
}
if (serviceName === 'Facebook') {
Expand Down
2 changes: 1 addition & 1 deletion app/tokenpass/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
forLoggedInUser: ['services.tokenpass'],
forOtherUsers: ['services.tokenpass.name'],
},
paramName: 'access_token',
accessTokenParam: 'access_token',
};

const Tokenpass = new CustomOAuth('tokenpass', config);
Expand Down
2 changes: 1 addition & 1 deletion app/wordpress/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = {
forLoggedInUser: ['services.wordpress'],
forOtherUsers: ['services.wordpress.user_login'],
},
paramName: 'access_token',
accessTokenParam: 'access_token',
};

const WordPress = new CustomOAuth('wordpress', config);
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"Accounts_OAuth_Custom_Identity_Token_Sent_Via": "Identity Token Sent Via",
"Accounts_OAuth_Custom_Login_Style": "Login Style",
"Accounts_OAuth_Custom_Merge_Users": "Merge users",
"Accounts_OAuth_Custom_Param_Name": "Param Name for access token",
"Accounts_OAuth_Custom_Access_Token_Param": "Param Name for access token",
"Accounts_OAuth_Custom_Scope": "Scope",
"Accounts_OAuth_Custom_Secret": "Secret",
"Accounts_OAuth_Custom_Token_Path": "Token Path",
Expand Down

0 comments on commit 3b010ff

Please sign in to comment.