UserModel::getByEmail PHP Méthode

getByEmail() public méthode

Get user by email address.
public getByEmail ( string $Email ) : array | boolean | stdClass
$Email string The email address of the user.
Résultat array | boolean | stdClass Returns the user or **false** if they don't exist.
    public function getByEmail($Email)
    {
        $this->userQuery();
        $User = $this->SQL->where('u.Email', $Email)->get()->firstRow();
        $this->setCalculatedFields($User);
        return $User;
    }

Usage Example

Exemple #1
0
 protected static function actionLogin()
 {
     if (empty($_POST)) {
         self::redirect(App::getLink('Auth'));
     }
     $errors = array();
     if (empty($_POST['email'])) {
         $errors['email'] = App::t('Введите email');
     } else {
         if (!preg_match('/^[-A-Za-z0-9_\\.]+@[-A-Za-z0-9_\\.]+\\.[a-z0-9]{2,4}$/', $_POST['email'])) {
             $errors['email'] = App::t('Некорректный email');
         }
     }
     if (empty($_POST['password'])) {
         $errors['password'] = App::t('Введите пароль');
     }
     if (empty($errors)) {
         $user = UserModel::getByEmail($_POST['email']);
         if (!$user) {
             $errors['email'] = App::t('Пользователь не найден');
         }
         if ($user->password == md5($_POST['password'])) {
             App::currentUser($user);
             self::redirect('/');
         } else {
             $errors['password'] = App::t('Неверный пароль');
         }
     }
 }
All Usage Examples Of UserModel::getByEmail
UserModel