Skip to content

Commit

Permalink
[IM] Better error when assigning an existing username to an edited user
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed May 8, 2014
1 parent 394a1ec commit 4ba8709
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion application/controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ protected function addPostValidate( $form, $object, $isEdit )
$object->setLastupdated( new DateTime() );
$object->setLastupdatedby( $this->getUser()->getId() );

$this->_processUser( $form, $object, $isEdit );
if( !$this->_processUser( $form, $object, $isEdit ) )
return false;

// let the group processor have the final say as to whether post validation
// passes or not
Expand Down Expand Up @@ -787,6 +788,14 @@ private function _processUser( $form, $contact, $isEdit )
);
}

// ensure the username is not already taken
if( $user->getUsername() != $form->getValue( "username" )
&& $this->getD2R( '\\Entities\\User' )->findOneBy( [ 'username' => $form->getValue( "username" ) ] ) )
{
$this->addMessage( 'That username is already is use by another user', OSS_Message::ERROR );
return false;
}

$user->setUsername( $form->getValue( "username" ) );
$user->setPrivs( $form->getValue( "privs" ) );
}
Expand All @@ -798,6 +807,8 @@ private function _processUser( $form, $contact, $isEdit )
if( $contact->getUser() )
$this->_deleteUser( $contact );
}

return true;
}


Expand Down

0 comments on commit 4ba8709

Please sign in to comment.