Symfony 3 在重置请求时出现 FosUserBundle 问题
Symfony 3 Problems FosUserBundle in resetting request
我在 4 小时前收到此消息错误,我试图解决它,但我不知道问题出在哪里。也许所有文件都配置错误?登录正常。
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
default_target_path: /
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
remember_me: true
remember_me:
secret: %secret%
#lifetime: 30000000
logout: true
anonymous: true
logout:
path: /logout
target: /login
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
# - { path: ^/listeUsers, role: ROLE_SUPER_ADMIN }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin/, role: ROLE_ADMIN }
# - { path: ^/ajouter, role: ROLE_ADMIN }
- { path: ^/index, role: IS_AUTHENTICATED_ANONYMOUSLY}
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
#http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
translator: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: gmail
host: "%mailer_host%"
username: 'digita****@gmail.com'
password: '*******'
spool: { type: memory }
#FOS USERBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: digita***.code@gmail.com
sender_name: DigitalCode - Sestem | Resetting Password
但是resetting/request不起作用。一直停留在登录界面。
我认为您在 access_control 中配置错误:
看到这个
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
并与此进行比较
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
我认为这应该可行:
- { path: ^/resetting$, role: IS_AUTHENTICATED_ANONYMOUSLY }
现在它应该可以工作了。我无法完全解释它,但对我来说,因为缺少正则表达式定界符,它似乎像给定的那样使用,而不是你想要的正则表达式。
第一个 Thunks 兄弟,
你是对的,我在 access_control 中犯了一个错误,现在它正在工作,但是这些配置没有 ReGex :
access_control:
- { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
问题已解决。
我在 4 小时前收到此消息错误,我试图解决它,但我不知道问题出在哪里。也许所有文件都配置错误?登录正常。
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
default_target_path: /
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
remember_me: true
remember_me:
secret: %secret%
#lifetime: 30000000
logout: true
anonymous: true
logout:
path: /logout
target: /login
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
# - { path: ^/listeUsers, role: ROLE_SUPER_ADMIN }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin/, role: ROLE_ADMIN }
# - { path: ^/ajouter, role: ROLE_ADMIN }
- { path: ^/index, role: IS_AUTHENTICATED_ANONYMOUSLY}
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
#http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
translator: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: gmail
host: "%mailer_host%"
username: 'digita****@gmail.com'
password: '*******'
spool: { type: memory }
#FOS USERBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: digita***.code@gmail.com
sender_name: DigitalCode - Sestem | Resetting Password
但是resetting/request不起作用。一直停留在登录界面。
我认为您在 access_control 中配置错误:
看到这个
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
并与此进行比较
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
我认为这应该可行:
- { path: ^/resetting$, role: IS_AUTHENTICATED_ANONYMOUSLY }
现在它应该可以工作了。我无法完全解释它,但对我来说,因为缺少正则表达式定界符,它似乎像给定的那样使用,而不是你想要的正则表达式。
第一个 Thunks 兄弟,
你是对的,我在 access_control 中犯了一个错误,现在它正在工作,但是这些配置没有 ReGex :
access_control:
- { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: ROLE_SUPER_ADMIN }
- { path: ^/, role: ROLE_SUPER_ADMIN }
问题已解决。