我正在创建一个带有前台和后台的新应用程序,我的bak办公室为创建社会提供了可能性,而在后端创建的那些社会应该为在前面的url中提供识别的可能性,我不知道该怎么办,..
我试图像这样=>
修改我的security.ymlaccess_control:
- { path: ^/\w+/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login_admin, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_USER }
- { path: ^/admin, roles: ROLE_ADMIN }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
并且我目前正试图在前台的网址中识别社会,就像这样(在我的config / routes.yaml中)=>
salarie_index:
path: /{_clientname}/*
而且工作正常,但是,当我尝试访问我的Bak办公室时,它现在被认为是一个社会> __ <“
我希望能够向我的路由指定,如果客户端名称为“ admin”,则它不应映射到该路由,...
答案 0 :(得分:0)
尽管我不清楚您要实现的目标,但似乎您过于复杂了。是什么让您无法选择不同的路线?
您可以为管理员设置一条路由:/admin
您的公司(协会)的另一条路线:/company/{_clientname}
答案 1 :(得分:0)
对不起,
我无法执行此操作,因为我的后台办公室不依赖公司,这意味着我根本不需要URL中的公司,而相反,这是前面URL中所需要的,...
事实上,我认为我可以在此处使用配置=>
routes.yml =>
#index:
# path: /
# controller: App\Controller\DefaultController::index
admin:
resource: "../../src/Controller/Admin/"
type: annotation
prefix: '/admin'
salarie:
resource: "../../src/Controller/Salarie/"
type: annotation
prefix: '/{_clientname}'
requirements:
_clientname: '^((\w+))+'
#_clientname: '^(((?!admin).)(\w+))+'
还有这个security.yml:
security:
encoders:
App\Entity\User:
algorithm: auto
App\Entity\Salarie:
algorithm: auto
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_salarie_provider:
entity:
class: App\Entity\Salarie
property: email
app_admin_provider:
entity:
class: App\Entity\AdminUser
property: email
# used to reload user from session & other features (e.g. switch_user)
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|ico|js)/
security: false
admin_area:
anonymous: true
pattern: ^/admin
provider: app_admin_provider
form_login:
provider: app_admin_provider
login_path: login_admin
username_parameter: sign_in[email]
password_parameter: sign_in[password]
check_path: login_check_admin
logout:
path: /logout_admin
target: /admin
salarie:
anonymous: true
pattern: ^/\w+
form_login:
provider: app_salarie_provider
login_path: login_salarie
username_parameter: sign_in[email]
password_parameter: sign_in[password]
check_path: login_check_salarie
logout:
path: /logout
target: /
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/\w+/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/, roles: ROLE_USER }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
有了这些文件,看起来我已经得到了我想要的结果!
以任何方式感谢您的回答,祝您有个美好的一天o /