Closed
Description
This tutorial needs more love. Here is a list of few things what i found confusing or incorrect:
- 1. discrepancy in table names. table "acme_users" declared in user class, but table "user" referenced in select query
select * from user;
- 2. missing
create table users
description. (this can be guessed by putting together information from annotations from user class and provided output of select query, but why so complicated?) - 3. missing reference on how to generate passwords with salt (provided link gives vague general idea but does not give answer on how to create password what would be usable in presented example)
- 4. some random, unexplained and possibly unrelated code: cleaning #2753
- 5.
you can still authenticate with maxime
- this is confusing, as it is the first time that somemaxime
is mentioned. missing password formaxime
and missing reference to when this authentification should be tried for the first time. also this would not work because user class is referencingUserRepository
in annotation, butUserRepository
was not yet defined. (it will be later in the tutorial) - 6. missing
create table acme_groups
declaration. - 7.
Group
should be renamed toRole
to avoid unnecessary confusion, and it should be declared asclass Role implements RoleInterface
- 7. tutorial should mention how to generate missing setters/getters by
php app/console doctrine:generate:entities Acme/UserBundle
(this does it for both User and Group as per http://symfony.com/doc/current/book/doctrine.html#generating-getters-and-setters ) - 8. missing at least 1 working example of user and password for testing (f.e.: u: 'admin', p: 'password', p-hash: 'd033e22ae348aeb5660fc2140aec35850c4da997', salt: '')
- 9. missing at least 1 working example of role/group and user assignment to this role/group.
- 10. missing explanation how is the user mapped to the role/group. this time not even
select * from groups
is provided
Question:
how should the user role be saved in the groups
table?
this is my users table
id | username | salt | password | is_active | |
---|---|---|---|---|---|
1 | admin | d033e22ae348aeb5660fc2140aec35850c4da997 |
admin@admin.com | 1 |
and this is my current groups table:
id | name | role |
---|---|---|
1 | admin | ROLE_ADMIN |
but when i login as admin/admin (yes admin is the correct password) the user role on return is empty.
Answer
ok i've noticed that after running table doctrine:generate:entities there is one more table created what mapps user to the role.