标签云

微信群

扫码加入我们

WeChat QR Code

Trying to change a torii authenticator to return an account id from the response, so it's available in the session for fetching the account. In trying to adapt the example to the torii authenticator, I have this starting point (obviously wrong, hitting on my js knowledge limits):import Ember from 'ember';import Torii from 'simple-auth-torii/authenticators/torii';import Configuration from 'simple-auth-oauth2/configuration';export default Torii.extend({authenticate: function(credentials) {return this._super(provider).then((authResponse) => {return new Ember.RSVP.Promise(function(resolve, reject) {Ember.$.ajax({url:Configuration.serverTokenEndpoint,type: 'POST',data: { 'auth_code': authResponse.authorizationCode }}).then(function(response) {Ember.run(function() {// all properties this promise resolves// with will be available through the sessionresolve({ access_token: response.access_token, account_id: response.account_id });});}, function(xhr, status, error) {Ember.run(function() {reject(xhr.responseText);});});});});}});Ember doesn't complain with any errors, but of course facebook's auth dialog doesn't pop. Lost at this point, any pointers would be greatly appreciated.UpdateThis is the provider code, which was working before changing the authenticator to try and return the account_id as well:import Ember from 'ember';import FacebookOauth2 from 'torii/providers/facebook-oauth2';let { resolve } = Ember.RSVP;export default FacebookOauth2.extend({fetch(data) {return resolve(data);},close() {return resolve();}});This is the previous, working authenticator:import Ember from 'ember';import Torii from 'simple-auth-torii/authenticators/torii';import Configuration from 'simple-auth-oauth2/configuration';export default Torii.extend({authenticate(provider) {return this._super(provider).then((authResponse) => {return Ember.$.post(Configuration.serverTokenEndpoint, { 'auth_code': authResponse.authorizationCode }).then(function(response) {return { 'access_token': response['access_token'], provider };});});}});


When Facebook's auth dialog doesn't show sth. is wrong with the provider - probably a misconfiguration or so. You'd want to step into the provider's open method with the debugger.

2019年04月22日29分25秒

Have you tried with multiple browsers? I wonder whether you're blocking pop-ups.

2019年04月22日29分25秒

brian yes, tried it with Chrome Canary, Safari and Firefox

2019年04月22日29分25秒

marcoow I added the code for the provider, and the previous authenticator, with which the former worked ok. I'm guessing it's something in the new resolving of promises by the new authenticator that's breaking it

2019年04月22日29分25秒