简体   繁体   English

使用ember应用,rails api和ember-cli-simple-auth-devise插件访问经过身份验证的用户

[英]Access the authenticated user with ember app, rails api, and ember-cli-simple-auth-devise addon

Following this tutorial 遵循本教程

http://givan.se/p/00000000 http://givan.se/p/00000000

I have setup authentication for an ember app with a grape api. 我已经为带有Grape api的ember应用设置了身份验证。 The tutorial doesn't store the current session, because there seems to be no need, however, I would like to access the current authenticated user in my api so that I can more easily handle deeply nested relationships. 本教程不存储当前会话,因为似乎没有必要,但是,我想在我的api中访问当前经过身份验证的用户,以便可以更轻松地处理深层嵌套的关系。 What would be the best way to accomplish this? 做到这一点的最佳方法是什么?

Currently using rails 4, and the latest versions of the grape and devise gems. 当前使用rails 4,以及葡萄的最新版本并设计出宝石。

<EDIT> <编辑>

Say I have a JSON payload like this 说我有这样的JSON负载

{ person: { user_id: 3, updated_attribute: 'the' } }

with my current setup, should I also include the user's authenticate token with each request to prevent a situation where a logged in user sends a PUT request where they have altered the user_id to update the attributes of another user. 在我当前的设置中,我还应该在每个请求中都包含用户的身份验证令牌,以防止登录用户发送PUT请求(如果他们更改了user_id以更新另一个用户的属性)。

I'm trying to understand how/make sure my rails server knows which user is making/submitting requests to the API. 我试图了解如何/确保我的Rails服务器知道哪个用户正在向API提交/提交请求。

从Ember Simple Auth存储库中查看此示例 -您只需定义一个自定义会话类,即可添加返回当前用户的计算属性。

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

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