root/trunk/wifidog-auth/wifidog/lost_password.php @ 530

Revision 530, 3.7 KB (checked in by fproulx, 8 years ago)

2005-04-01 Francois Proulx <francois.proulx@…>

  • EVERYTHING IS NOW UTF-8 YOU MUST EDIT YOUR FILES WITH AN UTF-8 COMPLIANT EDITOR
  • The database will be converted to UTF-8 (version 5)
  • Added select boxes ( or hidden ) html form elements to choose the network for signup, lost password, username
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2  // $Id$
3  /********************************************************************\
4   * This program is free software; you can redistribute it and/or    *
5   * modify it under the terms of the GNU General Public License as   *
6   * published by the Free Software Foundation; either version 2 of   *
7   * the License, or (at your option) any later version.              *
8   *                                                                  *
9   * This program 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 this program; if not, contact:                        *
16   *                                                                  *
17   * Free Software Foundation           Voice:  +1-617-542-5942       *
18   * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
19   * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
20   *                                                                  *
21   \********************************************************************/
22  /**@file
23   * Login page
24   * @author Copyright (C) 2004 Benoit Grégoire et Philippe April
25   */
26define('BASEPATH','./');
27require_once BASEPATH.'include/common.php';
28require_once BASEPATH.'include/common_interface.php';
29require_once BASEPATH.'classes/User.php';
30
31if (isset($_REQUEST['submit'])) {
32    if (!$_REQUEST['username'] && !$_REQUEST['email']) {
33        $smarty->assign("error", _("Please specify a username or email address"));
34    } else {
35        $username = $db->EscapeString($_REQUEST['username']);
36        $email = $db->EscapeString($_REQUEST['email']);
37        // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use
38                $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source'];
39
40        try {
41                if(empty($account_origin))
42                                throw new Exception(_("Sorry, this network does not exist !"));
43                               
44                // Get a list of users associated with either a username of an e-mail
45            $username && $user = User::getUserByUsernameAndOrigin($username, $account_origin);
46            $email && $user = User::getUserByEmailAndOrigin($email, $account_origin);
47           
48            // In the case that both previous function calls failed to return a users list
49            // Throw an exception
50            if($user != null)
51                    $user->sendLostPasswordEmail();
52                else
53                        throw new Exception(_("This username or email could not be found in our database"));
54               
55            $smarty->assign('message', _('A new password has been emailed to you.'));
56            $smarty->display('templates/validate.html');
57            exit;
58        } catch (Exception $e) {
59            $smarty->assign("error", $e->getMessage());
60        }
61    }
62}
63
64// Add the auth servers list to smarty variables
65$sources = array ();
66// Preserve keys
67foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key)
68        if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted())
69                $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key];
70
71isset ($sources) && $smarty->assign('auth_sources', $sources);
72// Pass the account_origin along, if it's set
73isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]);
74
75$smarty->display("templates/lost_password.html");
76?>
Note: See TracBrowser for help on using the browser.