Skip to content

Commit 9849b88

Browse files
committed
prefer const
1 parent 5187df5 commit 9849b88

File tree

2 files changed

+46
-27
lines changed

2 files changed

+46
-27
lines changed

addon/services/ember-oauth2.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default Service.extend(Evented, {
8484
On reject returns Object with reference to dialog and error.
8585
*/
8686
openWindow(url) {
87-
let dialog = window.open(url, 'Authorize', 'height=600, width=450');
87+
const dialog = window.open(url, 'Authorize', 'height=600, width=450');
8888
if (window.focus && dialog) {
8989
dialog.focus();
9090
}
@@ -107,8 +107,8 @@ export default Service.extend(Evented, {
107107
*/
108108

109109
handleRedirect: on('redirect', function(hash, callback) {
110-
let self = this;
111-
let params = self.parseCallback(hash);
110+
const self = this;
111+
const params = self.parseCallback(hash);
112112

113113
if (self.authSuccess(params) && self.checkState(params.state)) {
114114
if (self.get('responseType') === 'token') {
@@ -183,7 +183,7 @@ export default Service.extend(Evented, {
183183
@return {Object} The access_token object with info about the token
184184
*/
185185
generateToken(params) {
186-
let token = {};
186+
const token = {};
187187
token.provider_id = this.get('providerId');
188188
token.expires_in = this.expiresIn(params.expires_in);
189189
token.scope = this.get('scope');
@@ -240,9 +240,9 @@ export default Service.extend(Evented, {
240240
* @return {Object} The params returned from the OAuth2 provider
241241
*/
242242
parseCallback(locationHash) {
243-
let oauthParams = {};
244-
let queryString = locationHash.substring(locationHash.indexOf('?'));
245-
let regex = /([^#?&=]+)=([^&]*)/g;
243+
const oauthParams = {};
244+
const queryString = locationHash.substring(locationHash.indexOf('?'));
245+
const regex = /([^#?&=]+)=([^&]*)/g;
246246
let match;
247247
while ((match = regex.exec(queryString)) !== null) {
248248
oauthParams[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
@@ -279,7 +279,7 @@ export default Service.extend(Evented, {
279279
* @return {Object} request object
280280
*/
281281
requestObj() {
282-
let request = {};
282+
const request = {};
283283
request.response_type = this.get('responseType');
284284
request.providerId = this.get('providerId');
285285
request.clientId = this.get('clientId');
@@ -307,10 +307,10 @@ export default Service.extend(Evented, {
307307
* @return {Array} Keys used to remove states from localStorage
308308
*/
309309
clearStates() {
310-
let regex = new RegExp('^' + this.get('statePrefix') + '-.*', 'g');
310+
const regex = new RegExp('^' + this.get('statePrefix') + '-.*', 'g');
311311

312312
let name;
313-
let toRemove = [];
313+
const toRemove = [];
314314
for (let i = 0, l = window.localStorage.length; i < l; i++) {
315315
name = window.localStorage.key(i);
316316
if (name.match(regex)) {
@@ -347,7 +347,7 @@ export default Service.extend(Evented, {
347347
* @return {Object} Properties of the request state
348348
*/
349349
readState() {
350-
let stateObj = JSON.parse(window.localStorage.getItem(this.stateKeyName()));
350+
const stateObj = JSON.parse(window.localStorage.getItem(this.stateKeyName()));
351351
if (!stateObj) {
352352
return false;
353353
}
@@ -361,7 +361,7 @@ export default Service.extend(Evented, {
361361
*/
362362
uuid() {
363363
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
364-
let r = (Math.random() * 16) | 0,
364+
const r = (Math.random() * 16) | 0,
365365
v = c === 'x' ? r : (r & 0x3) | 0x8;
366366
return v.toString(16);
367367
});
@@ -404,7 +404,7 @@ export default Service.extend(Evented, {
404404
* @return {Object} The params from the OAuth2 response from localStorage with the key 'tokenPrefix-providerId'.
405405
*/
406406
getToken() {
407-
let token = JSON.parse(window.localStorage.getItem(this.tokenKeyName()));
407+
const token = JSON.parse(window.localStorage.getItem(this.tokenKeyName()));
408408
if (!token) {
409409
return null;
410410
}
@@ -419,7 +419,7 @@ export default Service.extend(Evented, {
419419
* @return {Object} The access_token param from the OAuth2 response from localStorage with the key 'tokenPrefix-providerId'.
420420
*/
421421
getAccessToken() {
422-
let token = this.getToken();
422+
const token = this.getToken();
423423
if (!token) {
424424
return null;
425425
}
@@ -450,7 +450,7 @@ export default Service.extend(Evented, {
450450
* @return {Boolean} Check if the access_token is expired.
451451
*/
452452
accessTokenIsExpired() {
453-
let token = this.getToken();
453+
const token = this.getToken();
454454
if (!token) {
455455
return true;
456456
}
@@ -466,7 +466,7 @@ export default Service.extend(Evented, {
466466
* @method expireAccessToken
467467
*/
468468
expireAccessToken() {
469-
let token = this.getToken();
469+
const token = this.getToken();
470470
if (!token) {
471471
return null;
472472
}

package-lock.json

Lines changed: 30 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)