-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(classic-test-app): remove actions hash, import action from @…
…ember/object
- Loading branch information
1 parent
10c3ba6
commit 1eab153
Showing
4 changed files
with
54 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,54 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@ember/component'; | ||
import config from '../config/environment'; | ||
import { action } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
session: service('session'), | ||
|
||
actions: { | ||
async authenticateWithOAuth2() { | ||
try { | ||
let { identification, password } = this; | ||
await this.get('session').authenticate('authenticator:oauth2', identification, password); | ||
|
||
if (this.rememberMe) { | ||
this.get('session').set('store.cookieExpirationTime', 60 * 60 * 24 * 14); | ||
} | ||
} catch (response) { | ||
let responseBody = await response.clone().json(); | ||
this.set('errorMessage', responseBody); | ||
authenticateWithOAuth2: action(async function (e) { | ||
e.preventDefault(); | ||
try { | ||
let { identification, password } = this; | ||
await this.get('session').authenticate('authenticator:oauth2', identification, password); | ||
|
||
if (this.rememberMe) { | ||
this.get('session').set('store.cookieExpirationTime', 60 * 60 * 24 * 14); | ||
} | ||
}, | ||
|
||
authenticateWithFacebook() { | ||
this.get('session').authenticate('authenticator:torii', 'facebook'); | ||
}, | ||
|
||
authenticateWithGoogleImplicitGrant() { | ||
let clientId = config.googleClientID; | ||
let redirectURI = `${window.location.origin}/callback`; | ||
let responseType = `token`; | ||
let scope = `email`; | ||
window.location.replace( | ||
`https://accounts.google.com/o/oauth2/v2/auth?` + | ||
`client_id=${clientId}` + | ||
`&redirect_uri=${redirectURI}` + | ||
`&response_type=${responseType}` + | ||
`&scope=${scope}` | ||
); | ||
}, | ||
|
||
updateIdentification(e) { | ||
this.set('identification', e.target.value); | ||
}, | ||
|
||
updatePassword(e) { | ||
this.set('password', e.target.value); | ||
}, | ||
|
||
updateRememberMe(e) { | ||
this.set('rememberMe', e.target.checked); | ||
}, | ||
}, | ||
} catch (response) { | ||
this.set('errorMessage', response.toString()); | ||
} | ||
}), | ||
|
||
authenticateWithFacebook: action(function (e) { | ||
e.preventDefault(); | ||
this.get('session').authenticate('authenticator:torii', 'facebook'); | ||
}), | ||
|
||
authenticateWithGoogleImplicitGrant: action(function (e) { | ||
e.preventDefault(); | ||
let clientId = config.googleClientID; | ||
let redirectURI = `${window.location.origin}/callback`; | ||
let responseType = `token`; | ||
let scope = `email`; | ||
window.location.replace( | ||
`https://accounts.google.com/o/oauth2/v2/auth?` + | ||
`client_id=${clientId}` + | ||
`&redirect_uri=${redirectURI}` + | ||
`&response_type=${responseType}` + | ||
`&scope=${scope}` | ||
); | ||
}), | ||
|
||
updateIdentification: action(function (e) { | ||
this.set('identification', e.target.value); | ||
}), | ||
|
||
updatePassword: action(function (e) { | ||
this.set('password', e.target.value); | ||
}), | ||
|
||
updateRememberMe: action(function (e) { | ||
this.set('rememberMe', e.target.checked); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@ember/component'; | ||
import { action } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
session: service('session'), | ||
sessionAccount: service('session-account'), | ||
|
||
actions: { | ||
logout() { | ||
this.get('session').invalidate(); | ||
}, | ||
}, | ||
logout: action(function () { | ||
this.get('session').invalidate(); | ||
}), | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/classic-test-app/app/templates/components/login-form.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
packages/classic-test-app/lib/my-engine/addon/controllers/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
|
||
export default Controller.extend({ | ||
session: service(), | ||
|
||
actions: { | ||
logout() { | ||
this.get('session').invalidate(); | ||
}, | ||
}, | ||
logout: action(function () { | ||
this.get('session').invalidate(); | ||
}), | ||
}); |