基于认证加载Backbone.js的资源 [英] loading backbone.js resources based on authentication

查看:113
本文介绍了基于认证加载Backbone.js的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建设我的第一个应用程序的骨干,虽然我做我的认证服务器端,有特色,非认证用户无法使用,但因为他们是在我的资产的路径,我的骨架的一部分文件,一切都被载入。

I'm building my first backbone app, and though I'm doing my authentication server side, there are features that non-authenticated users are unable to use, but because they are in my asset path, and part of my backbone files, everything gets loaded.

有没有办法只加载该用户实际能够使用的资源?

Is there a way to load only the resources that a user is actually able to use?

我使用Rails与康康舞来管理这些服务器端。

I'm using Rails with cancan to manage this server-side.

推荐答案

您需要分割资产出单独组:可以由任何人使用一组,并且可以通过身份验证的用户可以使用一组。只传送code,它允许用户使用,基本上是这样。

You need to split the assets out in to separate groups: a group that can be used by anyone, and a group that can be used by authenticated users. Only send the code that the user is allowed to use, basically.

我写了一篇关于最近与asp.net的MVC这样做。同样的想法适用于轨道,虽然资产使用管道使实现有点不同:

I wrote a post about doing this with asp.net mvc recently. the same idea applies to rails, though the use of the asset pipeline makes the implementation a bit different:

<一个href=\"http://lostechies.com/derickbailey/2012/01/26/modularity-and-security-in-composite-javascript-apps/\" rel=\"nofollow\">http://lostechies.com/derickbailey/2012/01/26/modularity-and-security-in-composite-javascript-apps/

这篇关于基于认证加载Backbone.js的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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