27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This chapter covers<br />

� Adding an authorization flag to a<br />

database table<br />

� Locking down access based on a<br />

database flag<br />

Basic access control<br />

As your application now stands, anybody, whether they’re signed in or not, can create<br />

new projects. As you did for the actions in the TicketsController, you must<br />

restrict access to the actions in the ProjectsController. The twist here is that<br />

you’ll allow only a certain subset of users—users with one particular attribute set in<br />

one particular way—to access the actions.<br />

You’ll track which users are administrators by putting a boolean field called<br />

admin in the users table. This is the most basic form of user authorization, which is<br />

not to be confused with authentication, which you implemented in chapter 6.<br />

Authentication is the process users go through to confirm their identity, whereas<br />

authorization is the process users go through to gain access to specific areas.<br />

136

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!