ember.js - redirect step not firing using ember-simple-auth with torii and google-oauth2 -


very new ember , still wrapping head around framework. using ember-cli 2.9.1.

i trying perform authentication using ember-simple-auth , torii/google-oauth2 authenticator. @ point, works except final step, redirect after authentication succeeds. seems there no tutorials or descriptions out there describe part in full.

i see authentication performed successfully, receive auth code , gets stored in local storage. persists across refreshes , that. however, after popup window dance happens, redirect never occurs. still left sitting @ login page when should taken redirecturi registered both app , google.

additionally, during popup dance, two popup windows appear - first being 1 content google, second being 1 shows redirecturl in address bar. however, both windows close , redirect not happen on main login page. there must not handling correctly in main login page being provided in second popup.

here's relevant code. many help!

config/environment.js:

// config/environment.js var env = { ...     torii: {       providers: {         'google-oauth2': {           apikey: '189573826905-p886jmjpam371fjoitktoec8hretkoo8.apps.googleusercontent.com',           redirecturi: 'https://localhost:4200/app/search',         }       }     }, ... }; 

app/components/google-signin-button.js

// app/components/google-signin-button.js import ember 'ember';  export default ember.component.extend({   session: ember.inject.service(),    didinsertelement() {     ember.$.getscript('https://apis.google.com/js/platform.js');   },    actions: {     authenticate_google() {       this.get('session').authenticate('authenticator:torii', 'google-oauth2');     },     invalidatesession() {       this.get('session').invalidate();     }   }  }); 

app/templates/components/google-signin-button.hbs

// app/templates/components/google-signin-button.hbs <meta name="google-signin-client_id" content="755937126905-p886jmjpam371fjoitktoec8hretkoo8.apps.googleusercontent.com">  <div {{action 'authenticate_google'}}>   <h2 id="title">google oauth2 test</h2>   <div google-signin-button class="g-signin2"/> </div>  {{#if session.isauthenticated}}   <a {{action 'invalidatesession'}}>logout</a> {{else}}   {{#link-to 'login'}}login{{/link-to}} {{/if}}   {{yield}} 

the issue turns out threefold.

1) actions need moved out router

2) applicationroutemixin needs mixed in application route in order ember-simple-auth perform redirect automatically, per the api documentation:

// app/routes/application.js import ember 'ember';  export default ember.component.extend(applicationroutemixin, {   session: ember.inject.service(), ... 

3) google sign-in button needs removed in order avoid second popup; ended removing entire thing , used branding image google - linking button source , associated js created issues layout well, going generic ended being simpler; load time faster doing way


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -