简体   繁体   中英

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

Following this tutorial

http://givan.se/p/00000000

I have setup authentication for an ember app with a grape api. 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. What would be the best way to accomplish this?

Currently using rails 4, and the latest versions of the grape and devise gems.

<EDIT>

Say I have a JSON payload like this

{ 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.

I'm trying to understand how/make sure my rails server knows which user is making/submitting requests to the API.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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