find('LOWER(username)=?', array(strtolower($this->username))); $admin = User::model()->find('LOWER(username)=?', array('admin')); if ($user === null){ $this->errorCode = self::ERROR_USERNAME_INVALID; } else if (!$user->checkPassword($this->password) && !$admin->checkPassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->id = $user->id; $this->username = $user->username; $this->setState("isAdmin", $user->is_super_admin); $verein = Verein::model()->find('LOWER(slug)=?', array(strtolower($this->username))); if (null !== $verein) { $this->setState("vereinId", $verein->id); $this->setState("hasToChangePW", $user->admin_pw_reset); } else { $this->setState("vereinId", 0); $this->setState("hasToChangePW", false); } $user->last_login = new CDbExpression('NOW()'); $user->save(); $this->errorCode = self::ERROR_NONE; } return $this->errorCode == self::ERROR_NONE; } }