简体   繁体   English

如何使用Ember简单身份验证获取当前已身份验证的用户?

[英]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.

相关问题 使用ember应用,rails api和ember-cli-simple-auth-devise插件访问经过身份验证的用户 - Access the authenticated user with ember app, rails api, and ember-cli-simple-auth-devise addon 在测试中使用ember-simple-auth-ephemeral存储区发出经过身份验证的请求 - Making authenticated requests with ember-simple-auth-ephemeral store in testing Rails和Ember简单身份验证 - Rails and Ember Simple Auth 灰烬简单身份验证基本URL - Ember Simple Auth Base URL 如果Rails正在处理登录表单,如何设置ember-simple-auth - How to setup ember-simple-auth if rails is handling the login forms 将帖子链接到经过身份验证的用户-如何在控制器中使用current_user? (设计) - Linking post to authenticated user - How do I use current_user in the controller? (devise) 如何更改已使用Devise标记进行身份验证的用户的“登录后路径”? - How do I change the 'after sign in path' for a user that has been authenticated with a token with Devise? 当用户未通过身份验证时,如何覆盖Devise使用的login_path? - How do I override the login_path that Devise uses when user not authenticated? 灰烬简单身份验证+设计抛出405 - Ember Simple Auth + Devise throws 405 如何正确到达数组的开头或结尾? 如何传递当前所选项目的参考? - How do I get to the beginning or end of the array properly? How do I pass in a reference of currently selected item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM