Marionette.js 与 Rails(设计)身份验证 [英] Marionette.js with Rails (Devise) Authentication

查看:25
本文介绍了Marionette.js 与 Rails(设计)身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很好奇人们通常如何处理这个问题.我的策略是拥有授权的根路由和未授权的根路由.

Curious as to how people usually handle this. My strategy is to have an authorized root route and unauthorized root route.

授权用户被直接发送到我的 marionette.js 单页应用程序,未经授权的用户被发送到一个标准的 Rails 登陆页面,可以选择登录或注册.

The authorized users get sent directly to my marionette.js single page application and unauthroized users get sent into a standard rails landing page with the option to login or register.

看来您可以将所有这些组合到您的单页应用程序中.您可以根据您根据查看它们所需的授权(注册、管理员、版主等)附加到元素的类来显示/隐藏 ui 元素.您还可以向路由器添加某种before_filter",以检查用户是否可以根据其角色访问此路由.

It seems you could combine these all into your single page application. You could show/hide ui elements based on a class you attach to elements based on the authorization needed to see them (registered, admin, moderator, etc). You could also add some kind of "before_filter" to your router's that can check whether or not the user can access this route given their role.

我不确定在这种情况下您将如何处理登录/注册.您可以设置自己的 api 路由,这些路由将 POST 交给要设计的工作?

I'm not sure exactly how you would handle login / registration in this case. You could setup your own api routes that get POST'd to which hand-off the work to devise?

想法?策略?这里的最佳实践是什么?

Thoughts? Strategies? What seems best practice here?

推荐答案

我发现尝试让 Backbone/Marionette 处理授权站点内容的身份验证和重新加载是痛苦且不必要的.他们登录后,将他们重定向到服务器处理的不同 URL,并让服务器以经过身份验证的用户身份发送他们需要的所有内容.

I find it painful and unnecessary to try and make Backbone/Marionette handle the authentication and re-loading of the authorized site stuff. Once they log in, redirect them to a different URL that the server handles, and have the server send down all the stuff that they need, as an authenticated user.

这篇关于Marionette.js 与 Rails(设计)身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆