0
我已经定义了使用骨干如何只允许
例如一组路线的具体途径获得:
Backbone.Routes.prefix = Onethingaday.Routers
Backbone.Routes.map
"!*splat":
"HomeRouter" : "reroute"
"":
"NavbarRouter" : "index"
"SidebarRouter" : "index"
"HomeRouter" : "index"
"all":
"NavbarRouter" : "index"
"SidebarRouter" : "index"
"HomeRouter" : "all"
"news":
"NavbarRouter" : "index"
"SidebarRouter" : "index"
"NotificationsRouter" : "index"
"popular/threads":
"NavbarRouter" : "index"
"SidebarRouter" : "index"
"DiscoverRouter" : "popularThreads"
现在,我要限制访问某些路线,即只能够访问“所有'和'新闻'路线,如果用户'登录'。我怎样才能在这里做支票?如果用户试图访问“全部”和“新闻”页面,例如
嗨,谢谢你的回复。是的,我已经有一种方法来知道用户是否已登录,所以我可以检查用户的isLoggedIn。我不确定的是我如何区分“登录”用户和“非登录”用户的路线。例如,对于'新闻'路线,登录用户应该可以访问无问题,但对于未登录的用户,我想将他重定向到单独的登录页面。基本上,如果用户未登录,我打算对差异路由采取一些不同的操作,例如,新闻 - >去登录页面,流行 - 允许访问等 – Zhen