Index: wp-login.php
===================================================================
--- wp-login.php	(revision 11216)
+++ wp-login.php	(working copy)
@@ -147,8 +147,13 @@
 	$message .= sprintf(__('Username: %s'), $user_login) . "\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";
-
-	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>');
 
 	return true;
@@ -174,19 +179,25 @@
 	if ( empty( $user ) )
 		return new WP_Error('invalid_key', __('Invalid key'));
 
-	do_action('password_reset', $user);
-
 	// Generate something random for a password...
 	$new_pass = wp_generate_password();
+	
+	do_action('password_reset', $user, $new_pass);
+
 	wp_set_password($new_pass, $user->ID);
 	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(__('Password: %s'), $new_pass) . "\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) )
-		die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
+	$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>');
+
 	wp_password_change_notification($user);
 
 	return true;
@@ -246,12 +257,16 @@
 // Main
 //
 
-$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
 $errors = new WP_Error();
 
 if ( isset($_GET['key']) )
 	$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();
 
 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
@@ -270,6 +285,9 @@
 if ( SITECOOKIEPATH != COOKIEPATH )
 	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']);
 switch ($action) {
 
@@ -517,4 +535,4 @@
 
 break;
 } // end action switch
-?>
+?>
\ No newline at end of file
