public function login(array $data, $check_password = true)
    {
        $result = array();
        $this->hook->attach('user.login.before', $data, $check_password, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (empty($data['email'])) {
            return $this->getResultErrorLogin();
        }

        $user = $this->user->getByEmail($data['email']);

        if (empty($user['status'])) {
            return $this->getResultErrorLogin();
        }

        if ($check_password && (!isset($data['password']) || !$this->user->passwordMatches($data['password'], $user))) {
            return $this->getResultErrorLogin();
        }

        $this->session->regenerate(true);
        $this->session->set('user', $user);

        $result = $this->getResultLogin($user);
        $this->hook->attach('user.login.after', $data, $check_password, $result, $this);

        return (array) $result;
    }