如何让所有用户路由到一个模块和一个登录 Symfony 的操作? [英] How to get all users routed to one module and one action on logon in Symfony?

查看:20
本文介绍了如何让所有用户路由到一个模块和一个登录 Symfony 的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的另一个问题 我发布了.

This follows on from my other question I posted.

我需要这样做,以便在任何人登录时都将他们重定向到特定模块 - sfGuardUser 和操作 isExistingUser.我知道这与路由有关,但我对这个文件完全一无所知,我无法理解它,而且在线教程对我来说都没有任何意义.

I need to make it so that when anyone logs in they are redirected to a particular module - sfGuardUser and action isExistingUser. I know it is somehting to do with the routing, but I am absolutely clueless with this file, I can't make head nor tail of it, and none of the tutorials online are making any sense to me.

问题更复杂(我认为),因为如果有人注销(单击链接注销)他们在浏览器中的 url 不会改变,因此如果他们从同一屏幕登录,symfony 会尝试将他们带到浏览器中已有的任何网址.我不确定如何在我的路由中说明这一点.

The problem is complicated (I think) further by the fact that if someone logs out (clicking a link logout) their url in the browser doesn't change, so therefore if they log on from that same screen, symfony tries to take them to whatever url they already have in their browser. I'm not sure how to account for this in my routing.

我有两个应用程序 - 前端和后端.我认为用户是从前端登录的(老实说我不确定),但我认为这是前端,因为当他们登录时,他们会被带到前端应用程序中的一个模块.尽管查看了两个应用程序的 settings.yml,但两个应用程序都启用了登录模块:S

I have two apps - frontend and backend. I think users log in from the frontend (I'm not sure to be honest), but I think it's the frontend because when they login, they are taken to a module int he frontend app. Although looking at the settings.yml for both apps, the login module is enabled for both :S

这是我的前端路由文件:

Here is my routing file for the front end:

   homepage:
     url:   /
     param: { module: investigation, action: isExistingUser }

   default_index:
     url:   /:module
     param: { module: investigation, action: isExistingUser }

   default:
     url:   /:module/:action/*
     param: { module: investigation, action: isExistingUser }

和后端:

homepage:
   url:   /
   param: { module: sfGuardUser, action: index }

sfGuardUser:
   url:   /sf_guard_user
   param: { module: sfGuardUser, action: index }

default_index:
   url:   /:module
   param: { action: index }

default:
   url:   /:module/:action/*

推荐答案

你在app.yml中为每个项目设置sign_in或sign_out之后使用的路由.

you set the route used after sign_in or sign_out in the app.yml for each project.

例如在 apps/(backend|frontend)/config/app.yml 中:

For example in apps/(backend|frontend)/config/app.yml:

all:
  sf_guard_plugin:
    success_signin_url:      @my_route?param=value # the plugin use the referer as default
    success_signout_url:     module/action         # the plugin use the referer as default

在 sfguardplugin 的额外文档中找到;)

found in the extra documentation of sfguardplugin ;)

这篇关于如何让所有用户路由到一个模块和一个登录 Symfony 的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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