copies straight from Subversion are also available. Details are in the CakePHPManual (seeResources).)
Section 2. Tor, so far
At the end ofPart 1, you were given an opportunity to put your skills to work bybuilding some missing functionality for Tor. Login/Logout, index, the use of hashedpasswords, and automatically logging a registering user were all on the to-do list.How did you do?
The login view
Your login view might look something like Listing 1.
Listing 1. Login view
<?phpif ($error){e('Invalid Login.');}?>Please log in.</p><?php echo $html->form('/users/login') ?><label>Username:</label><?php echo $html->input('User/username', array) ?><label>Password:</label><?php echo $html->password('User/password', array) ?><?php echo $html->submit('login') ?></form><?php echo $html->link('register', '/users/register') ?>
Your index view might look something like Listing 2.
Listing 2. Index view
<p>Hello, <?php e($User['first_name'] . ' ' . $User['last_name']) ?></p><p>Your last login was on <?php e($last_login) ?></p><?php echo $html->link('knownusers', '/users/knownusers') ?> <?php echo$html->link('logout', '/users/logout') ?>
Both of the views should look pretty straightforward. The index view just checks thesession for the user's username and, if it's not set, sends him to log in. The loginview doesn't set a specific error message, so someone trying to guess their way intothe system doesn't know which parts are correct.
Add a Comment
Anthoney_Wright_3490left a comment
alcooltanleft a comment
leleuleft a comment