public function disconnect() { $returnto = Ajde::app()->getRequest()->getParam('returnto', ''); if ($user = $this->getLoggedInUser()) { // should always be true, since we are inside a Ajde_User_Controller $sso = new SsoModel(); if ($sso->loadByFields(['user' => $user->getPK(), 'provider' => $this->_providername])) { $this->_provider->destroySession(); $sso->delete(); Ajde_Session_Flash::alert('Disconnected from ' . ucfirst($this->_providername)); $this->redirect($returnto); } else { Ajde_Session_Flash::alert('Could not disconnect from ' . ucfirst($this->_providername)); $this->redirect($returnto); } } }