Building a Password Reset Mechanism for Our Application

To complete the authentication system, we need the ability to reset the password should we forget what it is. Here are the steps to do so:

  1. Create a new method called reset in the Admin Controller.
  2. Again, check if the user is logged in and if they are, redirect them back to the admin.
  3. Set up an errors array and set the page title before loading a view called reset:
    public function reset()
        if (Session::get('logged_in')) {
        $errors = [];
        $title = 'Reset Account';
        $this->view->render('admin/auth/reset', compact('title', 'errors'));
  4. Now create a view called reset.php in app/views/admin/auth and enter:
    <?php include(APPDIR.'views/layouts/header.php');?> <div class="wrapper ...

Get Beginning PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.