Browse Source

[backend] Création utilisateur : vérification email

dev
Guillaume 4 years ago
parent
commit
f0b9956bfb
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      common/models/User.php

+ 6
- 1
common/models/User.php View File

@@ -220,7 +220,12 @@ class User extends ActiveRecordCommon implements IdentityInterface
*/
public function verifyEmail($attribute, $params)
{
$user = User::find()->where("email LIKE :email AND id != :id")->params(array(':email' => '%' . $this->email . '%', ':id' => $this->id))->one();
if($this->id) {
$user = User::find()->where("email LIKE :email AND id != :id")->params(array(':email' => '%' . $this->email . '%', ':id' => $this->id))->one();
}
else {
$user = User::find()->where("email LIKE :email")->params(array(':email' => '%' . $this->email . '%'))->one();
}

if ($user) {
$this->addError($attribute, 'Cette adresse email est déjà utilisée par un autre utilisateur ');

Loading…
Cancel
Save