[英]How do I get the currently authenticated user with Ember simple auth?
If a user starts out in my app unauthenticated and then logs in, I can have my Rails back-end return the user data, and create a User model in my Ember app. 如果用户在未经身份验证的情况下开始进入我的应用程序,然后登录,则可以让Rails后端返回用户数据,并在Ember应用程序中创建用户模型。
However, what if a user starts out in the app authenticated? 但是,如果用户在经过身份验证的应用程序中入门怎么办? How can I use session
to fetch the user's details from Rails? 如何使用session
从Rails中获取用户的详细信息?
I'm using the ember-simple-auth-devise authenticator. 我正在使用ember-simple-auth-devise身份验证器。
I was able to use 我能够使用
this.get('session.user_email')
in my application route to find the authenticated user. 在我的应用程序路由中找到经过身份验证的用户。
The better way to do it is to reopen the session
object and add a property that references the authenticated user. 更好的方法是重新打开session
对象并添加引用已验证用户的属性。 See this example from the guides . 请参阅指南中的示例 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.