Project

General

Profile

Revision b0dc3a2e

Added by Julien Enselme over 7 years ago

Update to Drupal 7.52

View differences:

drupal7/modules/user/user.pages.inc
44 44
    $form['name']['#value'] = $user->mail;
45 45
    $form['mail'] = array(
46 46
      '#prefix' => '<p>',
47
      // As of https://www.drupal.org/node/889772 the user no longer must log
48
      // out (if they are still logged in when using the password reset link,
49
      // they will be logged out automatically then), but this text is kept as
50
      // is to avoid breaking translations as well as to encourage the user to
51
      // log out manually at a time of their own choosing (when it will not
52
      // interrupt anything else they may have been in the middle of doing).
47 53
      '#markup' =>  t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the e-mail.', array('%email' => $user->mail)),
48 54
      '#suffix' => '</p>',
49 55
    );
......
54 60
  return $form;
55 61
}
56 62

  
63
/**
64
 * Form validation handler for user_pass().
65
 *
66
 * @see user_pass_submit()
67
 */
57 68
function user_pass_validate($form, &$form_state) {
58 69
  $name = trim($form_state['values']['name']);
59 70
  // Try to load by email.
......
72 83
  }
73 84
}
74 85

  
86
/**
87
 * Form submission handler for user_pass().
88
 *
89
 * @see user_pass_validate()
90
 */
75 91
function user_pass_submit($form, &$form_state) {
76 92
  global $language;
77 93

  
......
96 112
  // When processing the one-time login link, we have to make sure that a user
97 113
  // isn't already logged in.
98 114
  if ($user->uid) {
99
    // The existing user is already logged in.
115
    // The existing user is already logged in. Log them out and reload the
116
    // current page so the password reset process can continue.
100 117
    if ($user->uid == $uid) {
101
      drupal_set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/$user->uid/edit"))));
118
      // Preserve the current destination (if any) and ensure the redirect goes
119
      // back to the current page; any custom destination set in
120
      // hook_user_logout() and intended for regular logouts would not be
121
      // appropriate here.
122
      $destination = array();
123
      if (isset($_GET['destination'])) {
124
        $destination = drupal_get_destination();
125
      }
126
      user_logout_current_user();
127
      unset($_GET['destination']);
128
      drupal_goto(current_path(), array('query' => drupal_get_query_parameters() + $destination));
102 129
    }
103 130
    // A different user is already logged in on the computer.
104 131
    else {
......
110 137
        // Invalid one-time link specifies an unknown user.
111 138
        drupal_set_message(t('The one-time login link you clicked is invalid.'), 'error');
112 139
      }
140
      drupal_goto();
113 141
    }
114
    drupal_goto();
115 142
  }
116 143
  else {
117 144
    // Time out, in seconds, until login URL expires. Defaults to 24 hours =
......
168 195
 * Menu callback; logs the current user out, and redirects to the home page.
169 196
 */
170 197
function user_logout() {
198
  user_logout_current_user();
199
  drupal_goto();
200
}
201

  
202
/**
203
 * Logs the current user out.
204
 */
205
function user_logout_current_user() {
171 206
  global $user;
172 207

  
173 208
  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
......
176 211

  
177 212
  // Destroy the current session, and reset $user to the anonymous user.
178 213
  session_destroy();
179

  
180
  drupal_goto();
181 214
}
182 215

  
183 216
/**
......
294 327
}
295 328

  
296 329
/**
297
 * Validation function for the user account and profile editing form.
330
 * Form validation handler for user_profile_form().
331
 *
332
 * @see user_profile_form_submit()
298 333
 */
299 334
function user_profile_form_validate($form, &$form_state) {
300 335
  entity_form_field_validate('user', $form, $form_state);
301 336
}
302 337

  
303 338
/**
304
 * Submit function for the user account and profile editing form.
339
 * Form submission handler for user_profile_form().
340
 *
341
 * @see user_profile_form_validate()
305 342
 */
306 343
function user_profile_form_submit($form, &$form_state) {
307 344
  $account = $form_state['user'];

Also available in: Unified diff