简体   繁体   English

使用Ember-Simple-Auth-Devise.js回调的Ember-Simple-Auth 3.1

[英]Ember-Simple-Auth 3.1 using Ember-Simple-Auth-Devise.js Callback

I'm using Ember-Simple-Auth on an Ember-CLI project, and I'm also using the provided ember-simple-auth-devise authenticator that comes with 3.1. 我正在Ember-CLI项目上使用Ember-Simple-Auth,并且还使用了3.1附带的ember-simple-auth-devise身份验证器。 I'm able to login and logout successful, but I can't figure out where's the best place to put the callback (or when the promise resolves) upon successfully logging in. I want to be able to use the data returned by my API on my app after logging in. Any suggestions and advice would be highly appreciated! 我能够成功登录和注销,但是我无法弄清楚在成功登录后放置回调(或承诺解决的时间)的最佳位置。我希望能够使用我的API返回的数据登录后在我的应用上显示。任何建议和意见将不胜感激! If requested, I can also provide code samples (although I figured it wasn't necessary since what I have implemented thus far is nothing custom). 如果需要的话,我也可以提供代码示例(尽管我认为这是没有必要的,因为到目前为止我实现的都是自定义的)。

Thanks! 谢谢!

When the session is authenticated successfully, the sessionAuthenticationSucceeded action is triggered (see http://ember-simple-auth.simplabs.com/ember-simple-auth-api-docs.html#Ember-SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded , there are also more actions for other events). 成功验证会话后,会触发sessionAuthenticationSucceeded操作(请参阅http://ember-simple-auth.simplabs.com/ember-simple-auth-api-docs.html#Ember-SimpleAuth-ApplicationRouteMixin-sessionAuthenticationSucceeded ,还有其他事件的更多操作)。 So that's a good place to react to the session becoming authenticated. 因此,这是对会话进行身份验证作出反应的好地方。

As the authenticator will set all values the server responds with as properties on the session you could also define additional properties that depend on these - see example here (where the account property depends on the accountId property that's read from the server response): https://github.com/simplabs/ember-simple-auth/blob/master/examples/4-authenticated-account.html#L101 由于身份验证器将设置服务器响应的所有值作为会话上的属性,因此您还可以定义其他依赖于这些属性的属性-请参见此处的示例(其中account属性取决于从服务器响应读取的accountId属性): https: //github.com/simplabs/ember-simple-auth/blob/master/examples/4-authenticated-account.html#L101

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM