diff --git a/packages/classic-test-app/app/components/login-form.js b/packages/classic-test-app/app/components/login-form.js index c1ebbcd14..cb8d5abe3 100644 --- a/packages/classic-test-app/app/components/login-form.js +++ b/packages/classic-test-app/app/components/login-form.js @@ -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); + }), }); diff --git a/packages/classic-test-app/app/components/main-navigation.js b/packages/classic-test-app/app/components/main-navigation.js index e4c29afaa..fb6a07c5c 100644 --- a/packages/classic-test-app/app/components/main-navigation.js +++ b/packages/classic-test-app/app/components/main-navigation.js @@ -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(); + }), }); diff --git a/packages/classic-test-app/app/templates/components/login-form.hbs b/packages/classic-test-app/app/templates/components/login-form.hbs index 5a2aed97c..2df5adca5 100644 --- a/packages/classic-test-app/app/templates/components/login-form.hbs +++ b/packages/classic-test-app/app/templates/components/login-form.hbs @@ -1,20 +1,20 @@ {{! login form; the fields must be named "identification" and "password"; the controller action is "authenticate" }} -Login with Facebook +Login with Facebook
-Login with Google (Implicit Grant) +Login with Google (Implicit Grant)

or login with OAuth 2.0 Resource Owner Password Credentials:

-
+
- +
- +
- + @@ -30,4 +30,4 @@ Documentation of the error codes can be found in the Error Response section of RFC 6749.

-{{/if}} +{{/if}} \ No newline at end of file diff --git a/packages/classic-test-app/app/templates/components/main-navigation.hbs b/packages/classic-test-app/app/templates/components/main-navigation.hbs index 68b5c2dcc..b54058d5e 100644 --- a/packages/classic-test-app/app/templates/components/main-navigation.hbs +++ b/packages/classic-test-app/app/templates/components/main-navigation.hbs @@ -19,9 +19,9 @@ {{#if this.sessionAccount.account}} Signed in as {{this.sessionAccount.account.name}} {{/if}} - Logout + Logout {{else}} - Login + Login {{/if}}
\ No newline at end of file diff --git a/packages/classic-test-app/lib/my-engine/addon/controllers/index.js b/packages/classic-test-app/lib/my-engine/addon/controllers/index.js index 935eddc48..02ccd8249 100644 --- a/packages/classic-test-app/lib/my-engine/addon/controllers/index.js +++ b/packages/classic-test-app/lib/my-engine/addon/controllers/index.js @@ -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(); + }), }); diff --git a/packages/classic-test-app/lib/my-engine/addon/templates/index.hbs b/packages/classic-test-app/lib/my-engine/addon/templates/index.hbs index 2e65f6e08..839b70614 100644 --- a/packages/classic-test-app/lib/my-engine/addon/templates/index.hbs +++ b/packages/classic-test-app/lib/my-engine/addon/templates/index.hbs @@ -4,4 +4,4 @@
This is a protected page in an engine only visible to authenticated users!
- \ No newline at end of file + \ No newline at end of file diff --git a/packages/test-app/app/components/login-form.js b/packages/test-app/app/components/login-form.js index be65ee955..ad38d2aba 100644 --- a/packages/test-app/app/components/login-form.js +++ b/packages/test-app/app/components/login-form.js @@ -13,7 +13,8 @@ export default class LoginFormComponent extends Component { @tracked rememberMe; @action - async authenticateWithOAuth2() { + async authenticateWithOAuth2(event) { + event.preventDefault(); try { let { identification, password } = this; await this.session.authenticate('authenticator:oauth2', identification, password); diff --git a/packages/test-app/app/templates/application.hbs b/packages/test-app/app/templates/application.hbs index 0d2a6aca0..dce83c9e0 100644 --- a/packages/test-app/app/templates/application.hbs +++ b/packages/test-app/app/templates/application.hbs @@ -1,4 +1,4 @@ - +
{{outlet}} -
+ \ No newline at end of file diff --git a/packages/test-app/app/templates/components/login-form.hbs b/packages/test-app/app/templates/components/login-form.hbs index e3d45e5af..5c2885268 100644 --- a/packages/test-app/app/templates/components/login-form.hbs +++ b/packages/test-app/app/templates/components/login-form.hbs @@ -4,7 +4,7 @@ Login with Google (Implicit Grant)

or login with OAuth 2.0 Resource Owner Password Credentials:

-
+
@@ -30,4 +30,4 @@ Documentation of the error codes can be found in the Error Response section of RFC 6749.

-{{/if}} +{{/if}} \ No newline at end of file diff --git a/packages/test-app/lib/my-engine/addon/templates/protected.hbs b/packages/test-app/lib/my-engine/addon/templates/protected.hbs index 613ac510f..18b77ed37 100644 --- a/packages/test-app/lib/my-engine/addon/templates/protected.hbs +++ b/packages/test-app/lib/my-engine/addon/templates/protected.hbs @@ -4,4 +4,4 @@
This is a protected page in an engine only visible to authenticated users!
- \ No newline at end of file + \ No newline at end of file