/** * Unlink account * * @param int $key Account session key */ public static function unlink($key = 0) { // Revoke Token \Rest::get('https://accounts.google.com/o/oauth2/revoke', array('token' => $_SESSION['usernames'][$key]['credentials']['access_token'])); // Remove Data UsersModel::remove($_SESSION['usernames'][$key]['username']['id']); if (isset($_SESSION['usernames'][$key])) { $toRemove = $_SESSION['usernames'][$key]; unset($_SESSION['usernames'][$key]); if (isset($_SESSION['wizard']['source']) && $_SESSION['wizard']['source']['username']['id'] == $toRemove['username']['id']) { $_SESSION['wizard']['source'] = \Auth::userBeside($_SESSION['wizard']['destination']); } if (isset($_SESSION['wizard']['destination']) && $_SESSION['wizard']['destination']['username']['id'] == $toRemove['username']['id']) { $_SESSION['wizard']['destination'] = \Auth::userBeside($_SESSION['sync']['source']); } if ($_SESSION['current']['username']['id'] == $key && count($_SESSION['usernames'])) { end($_SESSION['usernames']); $_SESSION['current'] = current($_SESSION['usernames']); } } if (!count($_SESSION['usernames'])) { \Auth::logout(); } \Util::notice(array('type' => 'success', 'text' => 'The account has been successfully removed and its API tokens revoked.')); \Router::redirect('accounts'); }
public static function _setUsers($source = -1, $destination = -1) { // First access if (!isset($_SESSION['wizard']['source']) || is_null($_SESSION['wizard']['source']) || !$_SESSION['wizard']['source'] || !isset($_SESSION['wizard']['destination']) || is_null($_SESSION['wizard']['destination']) || !$_SESSION['wizard']['destination']) { $_SESSION['wizard']['source'] = $_SESSION['current']; $_SESSION['wizard']['destination'] = \Auth::userBeside($_SESSION['current']['username']['id']); } // Selected source and destination if ($source !== -1 && $destination !== -1) { if ($source == $destination) { if ($_SESSION['wizard']['source']['username']['id'] == $source) { $_SESSION['wizard']['source'] = \Auth::userBeside($source); $_SESSION['wizard']['destination'] = $_SESSION['usernames'][$destination]; } else { $_SESSION['wizard']['source'] = $_SESSION['usernames'][$source]; $_SESSION['wizard']['destination'] = \Auth::userBeside($source); } } else { $_SESSION['wizard']['source'] = $_SESSION['usernames'][$source]; $_SESSION['wizard']['destination'] = $_SESSION['usernames'][$destination]; } $_SESSION['current'] = $_SESSION['wizard']['source']; \Router::redirect('migrate'); } }