symfony - Symfony2 Doctrine use wrong alias in SQL, login fails with "Authentication request could not be processed [...]" -
i trying make own user bundle, , struggling @ login phase, error message :
authentication request not processed due system problem.
i'm kinda new symfony , doing best learn many aspects possible, please forgive me if took wrong path in defining stuff.
structure
i have 2 bundles, 1 app called scoreboardbundle, , 1 dedicated authenticating mechanic called pulsahr\userbundle. intend make bundle reusable in of projects.
user entity want use scoreboardbundle\entity\user, , inherits pulsahr\userbundle\entity\user, implements userinterface, \serializable.
log info
i looked dev.log, , found intriguing line :
[2016-09-22 14:16:19] security.info: authentication request failed. {"exception":"[object] (symfony\component\security\core\exception\authenticationserviceexception(code: 0): exception occurred while executing 'select t1.id id_2, t1.username username_3, t1.password password_4, t1.roles roles_5, t1.email email_6, t1.config config_7, t1.name name_8, t1.avatar avatar_9, t1.graph_color graph_color_10 from user t1 t0.username = ? limit 1' params [\"fdsfgsd\"]
i made mistake somewhere, doctrine looking t0.username without defining t0 alias. why ?
below several of files, hope help.
/src/pulsahr/userbundle/resources/config/doctrine/user.orm.yml :
pulsahr\userbundle\entity\user: type: entity table: user repositoryclass: pulsahr\userbundle\repository\userrepository id: id: type: integer id: true generator: strategy: auto fields: username: type: string length: 255 unique: true password: type: string length: 255 roles: type: array nullable: true lifecyclecallbacks: { }
/src/scoreboardbundle/resources/config/doctrine/user.orm.yml :
scoreboardbundle\entity\user: type: entity table: user repositoryclass: scoreboardbundle\repository\userrepository fields: email: type: string length: 255 config: type: integer name: type: string length: 127 avatar: type: string length: 255 nullable: true graphcolor: column: graph_color type: string length: 255 manytomany: races: targetentity: race mappedby: users onetomany: scores: targetentity: score mappedby: user lifecyclecallbacks: { }
/app/config/security.yml :
security: encoders: scoreboardbundle\user: algorithm: bcrypt cost: 4 role_hierarchy: role_raceadmin: role_user role_admin: role_raceadmin role_super_admin: [role_admin, role_allowed_to_switch] providers: pulsahr_userbundle: entity: class: scoreboardbundle:user property: username firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false pulsahr_user_security: anonymous: true form_login: login_path: pulsahr_user_login check_path: pulsahr_user_check provider: pulsahr_userbundle logout: path: pulsahr_user_logout target: pulsahr_user_login pattern: ^/ remember_me: secret: '%secret%' access_control: - { path: ^/admin, role: role_admin }
i had manually enter user, , used bcrypt calculator password, using 4 cost, same defined in security.yml. whatever login , password used, have same error message.
after many struggles, friend helped me find solution.
problem caused inheritance on scoreboardbundle\user\entity\user pulsahr\userbundle\entity\user.
php classes fine, problem comes mapping. had specify in user.orm.yaml origin class type "mappedsuperclass". doing this:
pulsahr\userbundle\entity\user: type: mappedsuperclass table: user [...]
more info on doctrine documentation : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html
hope people stuck me.
Comments
Post a Comment