[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/login/ -> forgot_password.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Forgot password routine.
  19   *
  20   * Finds the user and calls the appropriate routine for their authentication type.
  21   *
  22   * @package    core
  23   * @subpackage auth
  24   * @copyright  1999 onwards Martin Dougiamas  http://dougiamas.com
  25   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  require('../config.php');
  29  require_once($CFG->libdir.'/authlib.php');
  30  require_once (__DIR__ . '/lib.php');
  31  require_once ('forgot_password_form.php');
  32  require_once ('set_password_form.php');
  33  
  34  $token = optional_param('token', false, PARAM_ALPHANUM);
  35  
  36  //HTTPS is required in this page when $CFG->loginhttps enabled
  37  $PAGE->https_required();
  38  
  39  $PAGE->set_url('/login/forgot_password.php');
  40  $systemcontext = context_system::instance();
  41  $PAGE->set_context($systemcontext);
  42  
  43  // setup text strings
  44  $strforgotten = get_string('passwordforgotten');
  45  $strlogin     = get_string('login');
  46  
  47  $PAGE->navbar->add($strlogin, get_login_url());
  48  $PAGE->navbar->add($strforgotten);
  49  $PAGE->set_title($strforgotten);
  50  $PAGE->set_heading($COURSE->fullname);
  51  
  52  // if alternatepasswordurl is defined, then we'll just head there
  53  if (!empty($CFG->forgottenpasswordurl)) {
  54      redirect($CFG->forgottenpasswordurl);
  55  }
  56  
  57  // if you are logged in then you shouldn't be here!
  58  if (isloggedin() and !isguestuser()) {
  59      redirect($CFG->wwwroot.'/index.php', get_string('loginalready'), 5);
  60  }
  61  
  62  if (empty($token)) {
  63      // This is a new password reset request.
  64      // Process the request; identify the user & send confirmation email.
  65      core_login_process_password_reset_request();
  66  } else {
  67      // User clicked on confirmation link in email message
  68      // validate the token & set new password
  69      core_login_process_password_set($token);
  70  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1