Remote refresh meta tag on final step, in favor of redirection after login
[plewww.git] / planetlab / persons / reset_password.php
1 <?php
2 //
3 // Reset password form
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2007 The Trustees of Princeton University
7 //
8 // $Id$ $
9 //
10
11 // Get session and API handles
12 require_once 'plc_session.php';
13 global $plc, $api, $adm;
14
15 // Only display dialogs if the user is not logged in.
16 if ( !$plc->person) {
17     // Print header
18     require_once 'plc_drupal.php';
19     include 'plc_header.php';
20
21     if (!empty($_REQUEST['id']) && !empty($_REQUEST['key'])) {
22       $person_id = intval($_REQUEST['id']);
23       drupal_set_title('Password Reset: Confirmed');
24       if ($adm->ResetPassword($person_id, $_REQUEST['key']) != 1) {
25         print '<div class="messages error">' . $adm->error() . '.</div>';
26       } else {
27         print '<div class="messages status">';
28         print "Success!  We've sent you another e-mail with your new temporary password. <br/>"; 
29         print "You can login using this temporaray password.  <br/>"; 
30         print "Please change it once you login by visiting 'My Account' and updating your password. ";
31         print '</div>';
32       }
33     } elseif (!empty($_REQUEST['email'])) {
34       drupal_set_title('Password Reset: Request Sent');
35       if ($adm->ResetPassword($_REQUEST['email']) != 1) {
36         print '<div class="messages error">' . $adm->error() . '.</div>';
37       } else {
38         print '<div class="messages status">';
39         print "We've sent an e-mail to " . $_REQUEST['email'] . " that will allow you to confirm the password reset. <br/>";
40         print "Please check your email now and follow the link contained there to reset your password. ";
41         print '</div>';
42       }
43     } else {
44
45         drupal_set_title('Password Reset');
46         $self = $_SERVER['PHP_SELF'];
47         if (!empty($_SERVER['QUERY_STRING'])) {
48           $self .= "?" . $_SERVER['QUERY_STRING'];
49         }
50
51         // XXX Use our own stylesheet instead of drupal.css
52         print <<<EOF
53 <div class="content">
54 <form action="$self" method="post">
55
56 <table border="0" cellpadding="0" cellspacing="0" id="content">
57   <tr>
58     <td>
59       <div class="form-item">
60         E-mail: <span class="form-required" title="This field is required.">*</span></label>
61         <input type="text" maxlength="60" name="email" id="edit-name" size="30" value="" class="form-text required" />
62       </div>
63       <input type="submit" name="op" value="Reset password"  class="form-submit" />
64     </td>
65   </tr>
66 </table>
67
68 </form>
69 </div>
70 EOF;
71
72     }
73     include 'plc_footer.php';
74
75 } else {
76   // Otherwise display the user's account page.
77   Header("Location: /db/persons/index.php?id=" . $plc->person['person_id']);
78   exit();
79 }
80
81
82 ?>