protected function _tokenLogin(Request $request)
    {
        if (!empty($request->query['token'])) {
            $token = $request->query['token'];
            $Users = TableRegistry::get('User.Users');
            $exists = $Users
                ->find()
                ->select(['id', 'username'])
                ->where(['token' => $token, 'token_expiration <=' => time()])
                ->limit(1)
                ->first();

            if ($exists) {
                $user = $this->_findUser($exists->username);
                if (is_array($user)) {
                    $controller = $this->_registry->getController();
                    if (isset($user['password'])) {
                        unset($user['password']);
                    }
                    $controller->Auth->setUser($user);
                    $exists->updateToken();

                    return true;
                }
            }
        }

        return false;
    }