Filling in the gaps
So far, users can register for your application and see who has already
registered. The application needs some filling in. Using the skills
you've learned so far, try filling in some more functionality. Check
out
Part 2
for examples of the following.
Login
The login view should gather the user login information and submit it
to the users controller. The users controller should look to see if
the user is in the database and verify that the password is correct.
If the user has correctly logged in, write the username to session and
send the user to the index action.
Hints:
- Use the built in
$this->User->findByUsername($your_username_variable_here)
to search for the user in the database
- Write the user's name to
Session with
$this->Session->write('user', $your_username_variable_here)
Index
action
The index action should check to see if the user's name has been
written to the session. If the user's name has been written to the
session, pull that information from the database and present the user
with a customized greeting. If the user has not logged in, direct him
to the login action.
Logout
The logout action should delete the user's username from the session
and forward the user to the login action.
Bonus
Modify the register action to automatically log the user into the
system and forward the user to the index action. Modify the register
and login actions to use hashed passwords, rather than saving your
passwords in the database as plain text.
Don't worry too much if you get stuck.
Part 2
provides sample solutions to these problems. Then you'll jump right in
and build out the Tor application product gallery.
Happy coding!
|