[英]HWIOauthBundle not redirecting to desired path after login
I did as per documentation and resources from the Internet. 我是根据Internet上的文档和资源来做的。 but it is not redirecting user to
default_target_path
specified 但不会将用户重定向到指定的
default_target_path
here is my security.yml
这是我的
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
secured_area:
pattern: ^/user
anonymous: ~
oauth:
remember_me: true
resource_owners:
facebook: "/user/login/check-facebook"
# google: "/login/check-google"
# my_custom_provider: "/login/check-custom"
login_path: /user/login
check_path: /user/connect
use_forward: false
failure_path: /user/login
default_target_path: /user/like
provider: fos_userbundle
oauth_user_provider:
# oauth: ~
service: hwi_oauth.user.provider.fosub_bridge
logout: true
access_control:
- { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user(.*), roles: ROLE_USER }
and config.yml
is 和
config.yml
是
hwi_oauth:
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: secured_area
connect:
confirmation: true
resource_owners:
facebook:
type: facebook
client_id: id
client_secret: secret
scope: "email user_birthday"
paths:
email: email
birthday: user_birthday
fosub:
# try 30 times to check if a username is available (foo, foo1, foo2 etc)
username_iterations: 30
# mapping between resource owners (see below) and properties
properties:
facebook: fbID
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Auth\UserBundle\Entity\User
at the end it redirect me to , 最后,它将我重定向到
http://myurl/user/connect/service/facebook?key=1415715954
and displays output text as header.success
并将输出文本显示为
header.success
what should I do? 我该怎么办?
There was Typo there, simple mistake. 那里有错字,简单的错误。 as @StivenLlup suggested in comments,
正如@StivenLlup在评论中建议的那样,
I changed 我变了
access_control:
- { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user(.*), roles: ROLE_USER } # changed this
to 至
access_control:
- { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/, roles: ROLE_USER } # to this
If HWIOauthBundle service can't find correct path to redirect like /user/like
then this problem occurs 如果HWIOauthBundle服务找不到像
/user/like
重定向的正确路径,则会出现此问题
also if there is error in controller of specified path then also proper redirection does not work 同样如果指定路径的控制器中有错误,那么正确的重定向也将不起作用
adding correct path in access_control
solved it. 在
access_control
添加正确的路径可以解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.