No user is attached to project on creation


When I create a project, the creating user is not attached to the project, which means I can’t add new users to the project (since the “add user” operation isn’t available.

Did I miss something?

You should see an "Add User To Project" link in the right column "Operations" list when viewing the details of a project you created as shown on the attached image. Are you saying you are not seeing this?

How far along in the book (what chapter) are you?

I’m on chapter 10. But actually, even if i use the files from chapter 13 from the zip downloaded from the editor’s site, i get the same results.

I don’t have the added user to project once the project is created.

What part of the code associates the creating user to the new project?


There is not any code implemented that automatically associates the user who created the project as the "owner" of that project. Of course it makes perfect sense to do that, and it would make for a good addition to the application.

The answer to your question as to how to add a user at all is to be sure you are logged in as the “admin” user (aka ‘super’ user) that is introduced in Chapter 12 and the explicit assignment of user #1 (i.e. id=1) to this new role is on page 296 of the printed book. That user will have access and the link should display.

The project CRUD was introduced several chapters prior to user management and RBAC. In chapter 8 (pages 202-213) we are moving very quickly through the implementation of adding users to projects. On page 210, we show the add new user to project form before we implement the access check for RBAC to ensure proper permission. At that point, any user would be able to add a new user to a project, but once we wrap the display of the link (and the extra checkAccess() call in the actionAddUser() method), then it will restrict access to just those users who have been assigned the "createUser" permission. And, as you have pointed, out, we did not go back and alter the Project creation code (introduced several chapters prior) to ensure the user doing the project creation was automatically added as an "admin" for that project.

The book is attempting to cover a great many topics, and there were many constraints that would not allow all details of a fully completed application to be explicitly covered. The result is that there are many aspects of the TrackStar application that are left up to the reader to implement. My hope, however, is that the book exposes you to enough of the meaningful details to make it easy for you to fill-in some of these blanks.