使用ember.js时处理用户认证(Handling user authentication when using ember.js)

系统教程 行业动态 更新时间:2024-06-14 16:55:58
使用ember.js时处理用户认证(Handling user authentication when using ember.js)

我正在查找有关ember.js的文档和帖子,并使用ember.js和Rails。

我喜欢Rails提供API的想法,以及处理UI的ember.js,但我想知道如何插入用户身份验证。

例如,说我正在使用设计,我如何使用它与ember.js?

任何指针将不胜感激。

I was looking up documentation and posts on ember.js, and using ember.js with Rails.

I like the idea of Rails providing the API, and ember.js handling the UI, but I was wondering how to plug User authentication.

Eg, say I am using devise, how do I use it with ember.js?

Any pointers would be much appreciated.

最满意答案

更新2

查看这个新的github示例应用程序 , 该应用程序使用混合rails视图+ devise-variable-scoped的ember应用程序,该应用程序在ember 1.0.rc.1 + ember-data rev 11上运行,并保持has_many关系。

看看这个令牌认证项目还没有做好准备,但显示了很多承诺。 这对移动客户端apis来说很好,它可以对用户端进行身份验证,而不是简单的基于web的rails查看设计身份验证。

两者都提供了有趣和有争议的用例。 我期待着看到未来的发展。

更新1

我使用Devise将超级基本用户身份验证添加到Dgeb的ember-data示例应用程序中: https : //github.com/dgeb/ember_data_example/pull/17 。 我使用Rails控制器进行身份验证创建和范围设定,将current_user user_id添加到新的联系人记录的创建中,同时通过current_user.id将范围内的AMS数据提供给烬类应用程序。


我有一段时间有这个相同的问题,我已经能够找到具有用户身份验证和使用rails的唯一开源的示例应用程序是https://github.com/carvil/dash-it 。 他使用Rails-Devise登录视图,一旦用户登录,该视图就会将current_user信息传递给ember.js应用程序。

我知道很多其他人使用Devise token_authenticatable完全删除Rails视图并严格通过令牌在Ember应用中验证用户。 这可能是最好的方法,但我还没有尝试过在应用程序中实现它,而且我还没有找到任何开源应用程序可以使用此路线。

Ember的首席开发人员之一Tom Dale表示,他们对任何特定的用户身份验证解决方案都没有“优惠国家”地位,所以直到他们正式支持特定的解决方案或在框架中构建一个解决方案之前,假设Devise标记是最好的选择。

希望有比我更多的Ember /用户身份验证体验的人可以使用Ember的状态机和路由与基于令牌的用户身份验证结合使用并演示比https://github.com/carvil/dash-it更好的解决方案。

Update 2

Check out this new github example app that uses a hybrid rails view + devise-variable-scoped ember app that runs on ember 1.0.rc.1 + ember-data rev 11 and persists has_many relationships.

Check out this token authentication project that isn't quite ready but shows a lot of promise. This could be great for mobile client apis that authenticate users client-side, as opposed to simple web-based rails view devise auth.

Both provide for interesting and debatable use cases. I look forward to seeing where this goes in the future.

Update 1

I added super basic user auth using Devise to Dgeb's ember-data example app here: https://github.com/dgeb/ember_data_example/pull/17 . I used Rails controllers for auth creation and scoping, adding current_user user_id's to the creation of new Contact records, while feeding scoped AMS data to the ember app through current_user.id.


I've had this very same question for a while and the only open-source ember example app I've been able to find that has user authentication and uses rails is https://github.com/carvil/dash-it. He uses a Rails-Devise login view that passes along current_user info to an ember.js app once the user is logged in.

I know many other people use Devise token_authenticatable to completely remove Rails views and authenticate users in Ember apps strictly through tokens. This is probably the best way to go, but I haven't tried implementing it in an app myself yet, and I haven't found any open source apps that go this route.

Tom Dale, one of the lead developers of Ember, says that they don't have a "favored nation" status yet for any specific user auth solution, so until they either officially support a specific solution or build one into the framework, I'm assuming Devise tokens are the best way to go.

Hopefully someone that has more Ember/user auth experience than me can chime in and demonstrate a better solution than https://github.com/carvil/dash-it, using Ember's state machine and routing in combination with token-based user auth.

更多推荐

本文发布于:2023-04-10 11:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/76e14b2c5a9cdb99829ce6c27c4e57e8.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   js   ember   authentication   user

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!