Changeset 1656
- Timestamp:
- 08/19/08 22:25:19 (3 months ago)
- Files:
-
- trunk/bb-includes/registration-functions.php (modified) (3 diffs)
- trunk/bb-reset-password.php (modified) (1 diff)
- trunk/bb-templates/kakumei/password-reset.php (modified) (1 diff)
- trunk/bb-templates/kakumei/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bb-includes/registration-functions.php
r1599 r1656 78 78 79 79 if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) ) 80 return false;80 return new WP_Error('user_does_not_exist', __('The specified user does not exist.')); 81 81 82 82 $resetkey = substr(md5(wp_generate_password()), 0, 15); … … 92 92 ); 93 93 94 return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('Password Reset'), $message ); 94 $mail_result = bb_mail( 95 bb_get_user_email( $user->ID ), 96 bb_get_option('name') . ': ' . __('Password Reset'), 97 $message 98 ); 99 100 if (!$mail_result) { 101 return new WP_Error('sending_mail_failed', __('The email containing the password reset link could not be sent.')); 102 } else { 103 return true; 104 } 95 105 } 96 106 … … 111 121 $key = sanitize_user( $key ); 112 122 if ( empty( $key ) ) 113 bb_die(__('Key not found.'));123 return new WP_Error('key_not_found', __('Key not found.')); 114 124 if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) ) 115 bb_die(__('Key not found.'));116 if ( $user = new WP_User( $user_id ) ) :125 return new WP_Error('key_not_found', __('Key not found.')); 126 if ( $user = new WP_User( $user_id ) ) { 117 127 if ( bb_has_broken_pass( $user->ID ) ) 118 128 bb_block_current_user(); 119 129 if ( !$user->has_cap( 'change_user_password', $user->ID ) ) 120 bb_die( __('You are not allowed to change your password.'));130 return new WP_Error('permission_denied', __('You are not allowed to change your password.')); 121 131 $newpass = wp_generate_password(); 122 132 bb_update_user_password( $user->ID, $newpass ); 123 bb_send_pass ( $user->ID, $newpass ); 124 bb_update_usermeta( $user->ID, 'newpwdkey', '' ); 125 else : 126 bb_die(__('Key not found.')); 127 endif; 133 if (!bb_send_pass( $user->ID, $newpass )) { 134 return new WP_Error('sending_mail_failed', __('The email containing the new password could not be sent.')); 135 } else { 136 bb_update_usermeta( $user->ID, 'newpwdkey', '' ); 137 return true; 138 } 139 } else { 140 return new WP_Error('key_not_found', __('Key not found.')); 141 } 128 142 } 129 143 trunk/bb-reset-password.php
r1220 r1656 4 4 require_once( BB_PATH . BB_INC . 'registration-functions.php'); 5 5 6 $ reset= false;6 $error = false; 7 7 8 if ( $_POST ) : 9 $user_login = sanitize_user ( $_POST['user_login'] ); 10 if ( empty( $user_login ) ) 11 exit; 12 bb_reset_email( $user_login ); 13 endif; 8 if ( $_POST ) { 9 $action = 'send_key'; 10 $user_login = sanitize_user( $_POST['user_login'] ); 11 if ( empty( $user_login ) ) { 12 $error = __('No username specified'); 13 } else { 14 $send_key_result = bb_reset_email( $user_login ); 15 if ( is_wp_error( $send_key_result ) ) 16 $error = $send_key_result->get_error_message(); 17 } 18 } elseif ( isset( $_GET['key'] ) ) { 19 $action = 'reset_password'; 20 $reset_pasword_result = bb_reset_password( $_GET['key'] ); 21 if ( is_wp_error( $reset_pasword_result ) ) 22 $error = $reset_pasword_result->get_error_message(); 23 } 14 24 15 if ( isset( $_GET['key'] ) ) : 16 bb_reset_password( $_GET['key'] ); 17 $reset = true; 18 endif; 19 20 bb_load_template( 'password-reset.php', array('reset', 'user_login', 'reset') ); 25 bb_load_template( 'password-reset.php', array('action', 'error') ); 21 26 ?> trunk/bb-templates/kakumei/password-reset.php
r1575 r1656 5 5 <h2><?php _e('Password Reset'); ?></h2> 6 6 7 <?php if ( $ reset) : ?>8 <p ><?php _e('Your password has been reset and a new one has been mailed to you.'); ?></p>7 <?php if ( $error ) : ?> 8 <p class="notice error"><?php echo $error; ?></p> 9 9 <?php else : ?> 10 <p><?php _e('An email has been sent to the address we have on file for you. If you don’t get anything within a few minutes, or your email has changed, you may want to get in touch with the webmaster or forum administrator here.'); ?></p> 10 <?php switch ( $action ) : ?> 11 <?php case ( 'send_key' ) : ?> 12 <p class="notice"><?php _e('An email has been sent to the address we have on file for you. If you don’t get anything within a few minutes, or your email has changed, you may want to get in touch with the webmaster or forum administrator here.'); ?></p> 13 <?php break; ?> 14 <?php case ( 'reset_password' ) : ?> 15 <p class="notice"><?php _e('Your password has been reset and a new one has been mailed to you.'); ?></p> 16 <?php break; ?> 17 <?php endswitch; ?> 11 18 <?php endif; ?> 12 19 trunk/bb-templates/kakumei/style.css
r1625 r1656 176 176 padding: 10px 15px; 177 177 margin: 0 0 1.1em; 178 } 179 180 .notice.error { 181 border-color: #852424; 182 background-color: #ca8a8a; 183 color: #5d2424; 178 184 } 179 185