我正在尝试使用自己的OAuth流程和Ember-Simple-Auth设置Torii。我可以获得成功的身份验证事件,但是在我进行身份验证后,立即invalidateSession
触发触发器,导致会话结束。我通过拦截看到sessionInvalidated()
的/app/routes/application.js
(具有ApplicationRouteMixin
)。
你们有没有遇到过这个?是否有某些特殊情况会导致立即进行会话验证?任何建议将不胜感激。
编辑:我认为这与torii弹出代码有关,因为第一个返回有效,但第二个却没有。有什么想法吗?
import OAuth2 from 'torii/providers/oauth2-code';
import {configurable} from 'torii/configuration';
export default OAuth2.extend({
name: 'api',
init() { this.set('clientID', this.get('apiKey')); },
baseUrl: configurable('baseUrl'),
redirectUri: configurable('redirectUri'),
responseParams: ['access_token', 'user_id', 'first_name'],
requiredUrlParams: ['client_id', 'redirect_uri', 'response_type'],
open() {
let name = this.get('name');
let url = this.buildUrl();
let redirectUri = this.get('redirectUri');
let responseParams = this.get('responseParams');
// this return works
return { 'yes' : 'no' }
// this return causes the immediate invalidation
return this.get('popup').open(url, responseParams).then((authData) => {
var missingResponseParams = [];
responseParams.forEach(function(param){
if (authData[param] === undefined) {
missingResponseParams.push(param);
}
});
if (missingResponseParams.length){
throw new Error("The response from the provider is missing " +
"these required response params: " + missingResponseParams.join(', '));
}
return {
access_token: authData.access_token,
first_name: authData.first_name,
user_id: authData.user_id,
provider: name,
redirectUri: redirectUri
};
});
}
});
真正的答案是使用此分叉:https : //github.com/simplabs/ember-simple-auth/pull/931(希望它将很快成为主服务器)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句