/**
*
*
* @param string $UserReference
* @param string $Username
* @param $Provider
* @throws Exception
*/
public function disconnect($UserReference = '', $Username = '', $Provider)
{
if (!Gdn::request()->isAuthenticatedPostBack(true)) {
throw new Exception('Requires POST', 405);
}
$this->permission('Garden.SignIn.Allow');
$this->getUserInfo($UserReference, $Username, '', true);
// First try and delete the authentication the fast way.
Gdn::sql()->delete('UserAuthentication', array('UserID' => $this->User->UserID, 'ProviderKey' => $Provider));
// Delete the profile information.
Gdn::userModel()->saveAttribute($this->User->UserID, $Provider, null);
if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
redirect(userUrl($this->User), '', 'connections');
} else {
// Grab all of the providers again.
$PModel = new Gdn_AuthenticationProviderModel();
$Providers = $PModel->getProviders();
$this->setData('_Providers', $Providers);
$this->setData('Connections', array());
$this->fireEvent('GetConnections');
// Send back the connection button.
$Connection = $this->data("Connections.{$Provider}");
require_once $this->fetchViewLocation('connection_functions');
$this->jsonTarget("#Provider_{$Provider} .ActivateSlider", connectButton($Connection), 'ReplaceWith');
$this->render('Blank', 'Utility', 'Dashboard');
}
}