Skip to content

Commit d7e7cfc

Browse files
bekzodGaurav0
authored andcommitted
small es6 cleanup to torri app adapter
1 parent 7edc14d commit d7e7cfc

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

app/torii-adapters/application.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import config from '../config/environment';
21
import Ember from 'ember';
2+
import config from '../config/environment';
33

44
const { inject, isBlank, RSVP } = Ember;
55

@@ -13,27 +13,27 @@ export default Ember.Object.extend({ /**
1313
ajax: inject.service(),
1414
fastboot: inject.service(),
1515

16-
resolveUser (token) {
16+
resolveUser(token) {
1717
config.TMP_TORII_TOKEN = token;
18-
return this.get('store').find('user', 'current').then((user) => {
18+
return this.get('store').find('user', 'current').then((currentUser) => {
1919
config.TMP_TORII_TOKEN = null;
2020
if (!this.get('fastboot.isFastBoot')) {
2121
localStorage.setItem('fiddle_gh_session', token);
2222
}
23-
return { currentUser: user, token: token };
23+
return { currentUser, token };
2424
});
2525
},
2626

2727
/**
2828
* Try loading the user from cookie
2929
* @return Promise
3030
*/
31-
fetch () {
31+
fetch() {
3232
if (this.get('fastboot.isFastBoot')) {
3333
return RSVP.reject();
3434
}
3535

36-
var token = localStorage.getItem('fiddle_gh_session');
36+
let token = localStorage.getItem('fiddle_gh_session');
3737

3838
if (isBlank(token)) {
3939
return RSVP.reject();
@@ -46,21 +46,23 @@ export default Ember.Object.extend({ /**
4646
* Open a new session, authenticate with Github
4747
* @return Promise
4848
*/
49-
open (authorization) {
50-
return this.get('ajax').request(config.githubOauthUrl + authorization.authorizationCode).then(result => this.resolveUser(result.token));
49+
open(authorization) {
50+
let url = config.githubOauthUrl + authorization.authorizationCode;
51+
return this.get('ajax').request(url)
52+
.then(result => this.resolveUser(result.token));
5153
},
5254

5355

5456
/**
5557
* Close a session
5658
* @return Promise
5759
*/
58-
close () {
60+
close() {
5961
if (this.get('fastboot.isFastBoot')) {
60-
return Ember.RSVP.reject();
62+
return RSVP.reject();
6163
} else {
6264
localStorage.removeItem('fiddle_gh_session');
63-
return Ember.RSVP.resolve();
65+
return RSVP.resolve();
6466
}
6567
}
6668
});

0 commit comments

Comments
 (0)