2016-02-29 96 views
1

4小時前我有這個消息錯誤,我試圖解決它,但我不知道問題在哪裏。也許所有的文件配置錯誤?登錄是可以的。Symfony 3問題FosUserBundle重置請求

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***[email protected] 
     sender_name: DigitalCode - Sestem | Resetting Password 

但復位/請求不起作用。它留在登錄界面上。

回答

1

首先的thunk兄弟,

妳對的,我犯了一個錯誤在ACCESS_CONTROL,現在它的工作,但與沒有正則表達式的配置:

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 } 

問題就迎刃而解了。

0

我認爲你必須在ACCESS_CONTROL配置錯誤:

看到這個

- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 

,並與該

- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } 

我認爲這應該工作比較:

- { path: ^/resetting$, role: IS_AUTHENTICATED_ANONYMOUSLY } 

現在它應該工作。我不能完全解釋它,但對於我來說,因爲正則表達式分隔符是缺少的,它似乎像它的使用,而不是你想要的正則表達式。

+0

$在網址做什麼? –