Make login more pluggable. Props Denis-de-Bernardy. fixes #9682
git-svn-id: http://svn.automattic.com/wordpress/trunk@11291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
91411dde28
commit
629775df07
28
wp-login.php
28
wp-login.php
|
@ -148,7 +148,12 @@ function retrieve_password() {
|
||||||
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
|
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
|
||||||
$message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
|
$message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
|
||||||
|
|
||||||
if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
|
$title = sprintf(__('[%s] Password Reset'), get_option('blogname'));
|
||||||
|
|
||||||
|
$title = apply_filters('retrieve_password_title', $title);
|
||||||
|
$message = apply_filters('retrieve_password_message', $message, $key);
|
||||||
|
|
||||||
|
if ( $message && !wp_mail($user_email, $title, $message) )
|
||||||
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -174,17 +179,23 @@ function reset_password($key) {
|
||||||
if ( empty( $user ) )
|
if ( empty( $user ) )
|
||||||
return new WP_Error('invalid_key', __('Invalid key'));
|
return new WP_Error('invalid_key', __('Invalid key'));
|
||||||
|
|
||||||
do_action('password_reset', $user);
|
|
||||||
|
|
||||||
// Generate something random for a password...
|
// Generate something random for a password...
|
||||||
$new_pass = wp_generate_password();
|
$new_pass = wp_generate_password();
|
||||||
|
|
||||||
|
do_action('password_reset', $user, $new_pass);
|
||||||
|
|
||||||
wp_set_password($new_pass, $user->ID);
|
wp_set_password($new_pass, $user->ID);
|
||||||
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
|
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
|
||||||
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
||||||
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
||||||
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
||||||
|
|
||||||
if ( !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
|
$title = sprintf(__('[%s] Your new password'), get_option('blogname'));
|
||||||
|
|
||||||
|
$title = apply_filters('password_reset_title', $title);
|
||||||
|
$message = apply_filters('password_reset_message', $message, $new_pass);
|
||||||
|
|
||||||
|
if ( $message && !wp_mail($user->user_email, $title, $message) )
|
||||||
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
||||||
|
|
||||||
wp_password_change_notification($user);
|
wp_password_change_notification($user);
|
||||||
|
@ -246,12 +257,16 @@ function register_new_user($user_login, $user_email) {
|
||||||
// Main
|
// Main
|
||||||
//
|
//
|
||||||
|
|
||||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
|
||||||
$errors = new WP_Error();
|
$errors = new WP_Error();
|
||||||
|
|
||||||
if ( isset($_GET['key']) )
|
if ( isset($_GET['key']) )
|
||||||
$action = 'resetpass';
|
$action = 'resetpass';
|
||||||
|
|
||||||
|
// validate action so as to default to the login screen
|
||||||
|
if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action) )
|
||||||
|
$action = 'login';
|
||||||
|
|
||||||
nocache_headers();
|
nocache_headers();
|
||||||
|
|
||||||
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
|
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
|
||||||
|
@ -270,6 +285,9 @@ setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
|
||||||
if ( SITECOOKIEPATH != COOKIEPATH )
|
if ( SITECOOKIEPATH != COOKIEPATH )
|
||||||
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
||||||
|
|
||||||
|
// allow plugins to override the default actions, and to add extra actions if they want
|
||||||
|
do_action('login_form_' . $action);
|
||||||
|
|
||||||
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue