Skip to content

Commit

Permalink
Implement UserPasswordMismatch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Dec 18, 2011
1 parent 495c709 commit 3cfb608
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions application/MantisBT/Exception/User/UserPasswordMismatch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace MantisBT\Exception\User;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class UserPasswordMismatch extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_USER_CREATE_PASSWORD_MISMATCH, null, false);
parent::__construct(ERROR_USER_CREATE_PASSWORD_MISMATCH, $errorMessage, null);
$this->responseCode = 400;
}
}
4 changes: 3 additions & 1 deletion public/account_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @uses utility_api.php
*/

use MantisBT\Exception\User\UserPasswordMismatch;

/**
* MantisBT Core API's
*/
Expand Down Expand Up @@ -110,7 +112,7 @@
# Update password if the two match and are not empty
if ( !is_blank( $f_password ) ) {
if ( $f_password != $f_password_confirm ) {
trigger_error( ERROR_USER_CREATE_PASSWORD_MISMATCH, ERROR );
throw new UserPasswordMismatch();
} else {
if ( !auth_does_password_match( $t_user_id, $f_password ) ) {
user_set_password( $t_user_id, $f_password );
Expand Down
3 changes: 2 additions & 1 deletion public/manage_user_create.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/

use MantisBT\Exception\Field\EmptyField;
use MantisBT\Exception\User\UserPasswordMismatch;

require_once( 'core.php' );
require_api( 'access_api.php' );
Expand Down Expand Up @@ -84,7 +85,7 @@
user_ensure_realname_unique( $f_username, $f_realname );

if ( $f_password != $f_password_verify ) {
trigger_error( ERROR_USER_CREATE_PASSWORD_MISMATCH, ERROR );
throw new UserPasswordMismatch();
}

$f_email = email_append_domain( $f_email );
Expand Down

0 comments on commit 3cfb608

Please sign in to comment.