Make hardcoded exception messages translatable
This commit is contained in:
parent
618914282a
commit
a4f42676ea
|
@ -239,24 +239,25 @@ class Manager extends PublicEmitter {
|
|||
* @return bool | \OC\User\User the created user of false
|
||||
*/
|
||||
public function createUser($uid, $password) {
|
||||
$l = \OC_L10N::get('lib');
|
||||
// Check the name for bad characters
|
||||
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
|
||||
if (preg_match('/[^a-zA-Z0-9 _\.@\-]/', $uid)) {
|
||||
throw new \Exception('Only the following characters are allowed in a username:'
|
||||
. ' "a-z", "A-Z", "0-9", and "_.@-"');
|
||||
throw new \Exception($l->t('Only the following characters are allowed in a username:'
|
||||
. ' "a-z", "A-Z", "0-9", and "_.@-"'));
|
||||
}
|
||||
// No empty username
|
||||
if (trim($uid) == '') {
|
||||
throw new \Exception('A valid username must be provided');
|
||||
throw new \Exception($l->t('A valid username must be provided'));
|
||||
}
|
||||
// No empty password
|
||||
if (trim($password) == '') {
|
||||
throw new \Exception('A valid password must be provided');
|
||||
throw new \Exception($l->t('A valid password must be provided'));
|
||||
}
|
||||
|
||||
// Check if user already exists
|
||||
if ($this->userExists($uid)) {
|
||||
throw new \Exception('The username is already being used');
|
||||
throw new \Exception($l->t('The username is already being used'));
|
||||
}
|
||||
|
||||
$this->emit('\OC\User', 'preCreateUser', array($uid, $password));
|
||||
|
|
Loading…
Reference in New Issue