[英]Ember Simple Auth with Multiple Devise Scopes
I have the following scenario: 我有以下场景:
Created on ember app on router: 在路由器上的ember app上创建:
Router.map(function() { this.route('panel', function() { this.route('login'); this.route('logout'); }); this.route('admin', function() { this.route('login'); this.route('logout'); }); });
I'm using jj-abrams
branch once my app is Ember 2.0 我的应用程序是Ember 2.0后,我正在使用
jj-abrams
分支
Both authenticating on /users/sign_in
and /admins/sign_in
两者都在
/users/sign_in
和/admins/sign_in
上进行身份验证
I followed steps on https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise#server-side-setup and authentication is working. 我按照https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise#server-side-setup上的步骤操作,验证工作正常。
Ember is hitting the right urls after creating authenticators and adapters, but the problem is that ESA just have one session service. 在创建身份验证器和适配器之后,Ember正在访问正确的URL,但问题是ESA只有一个会话服务。 Once user or admin is logged in
session.isAuthenticated
is true and I don't know which scopes are logged in. 一旦用户或管理员登录
session.isAuthenticated
为true,我不知道登录的是哪个范围。
Which is the best way to proceed: 哪种方式最好:
role
on user reply and set on session role
并在会话上设置 I solved this problema creating 3 authenticators for each scope, and I handle each one. 我解决了这个问题,为每个范围创建3个身份验证器,我处理每个范围。
It is a particular solution once I don't use other authenticators (OAuth2), but now I can check if authenticator:user
, authenticator:admin
, authenticator:manager
was used on to login. 一旦我不使用其他验证器(OAuth2),这是一个特殊的解决方案,但现在我可以检查
authenticator:user
, authenticator:admin
, authenticator:manager
已用于登录。
I have created checks on routes, so user can only access his panel, admin can access user and admin panel, and manager can access the whole system. 我已经创建了路由检查,因此用户只能访问他的面板,管理员可以访问用户和管理面板,管理员可以访问整个系统。
I've posted the ember and the API on github: 我在github上发布了ember和API:
ps: I think would be better to create sessions for each scope, but I don't know how to do it (and if its better or not), in this solution you can login one scope at once (not like devise on rails you can log with many scopes at once). ps:我认为最好为每个范围创建会话,但我不知道如何做(如果它更好或没有),在这个解决方案中你可以一次登录一个范围(不像你在轨道上设计)可以一次登录多个范围)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.