public function ajax_connect_clef_account_with_oauth_code()
 {
     if (!ClefUtils::isset_POST('identifier')) {
         return new WP_Error("invalid_oauth_code", __("invalid OAuth Code", "clef"));
     }
     try {
         $info = ClefUtils::exchange_oauth_code_for_info(ClefUtils::isset_POST('identifier'), $this->settings);
     } catch (LoginException $e) {
         return new WP_Error("bad_oauth_exchange", $e->getMessage());
     }
     $result = ClefUtils::associate_clef_id($info->id);
     if (is_wp_error($result)) {
         return $result;
     } else {
         $session = ClefSession::start();
         $session->set('logged_in_at', time());
         return array("success" => true);
     }
 }
 public static function verify_state()
 {
     $state = ClefUtils::isset_GET('state') ? ClefUtils::isset_GET('state') : ClefUtils::isset_POST('state');
     $session = ClefSession::start();
     if ($session->get('state') && $state && $session->get('state') == $state) {
         $session->set('state', null);
         return true;
     } else {
         throw new ClefStateException('The state parameter is not verified. Please refresh your page and try again, you may be experiencing a CSRF attempt');
     }
 }
Ejemplo n.º 3
0
 public function ajax_connect_clef_account_with_clef_id()
 {
     if (!ClefUtils::isset_POST('identifier')) {
         return new WP_Error("invalid_clef_id", __("invalid Clef ID", "wpclef"));
     }
     $result = ClefUtils::associate_clef_id($_POST["identifier"]);
     if (is_wp_error($result)) {
         return $result;
     } else {
         $session = ClefSession::start();
         $session->set('logged_in_at', time());
         return array("success" => true);
     }
 }
Ejemplo n.º 4
0
 public static function verify_state()
 {
     $request_state = ClefUtils::isset_GET('state') ? ClefUtils::isset_GET('state') : ClefUtils::isset_POST('state');
     $correct_state = ClefUtils::get_state();
     if ($request_state && $correct_state && $correct_state == $request_state) {
         ClefUtils::initialize_state(true);
         return true;
     } else {
         throw new ClefStateException('The state parameter is not verified. This may be due to this page being cached by another WordPress plugin. Please refresh your page and try again');
     }
 }
Ejemplo n.º 5
0
 public function connect_clef_account_on_login($user)
 {
     if (ClefUtils::isset_POST('clef_id') && $user && !is_wp_error($user)) {
         ClefUtils::associate_clef_id(ClefUtils::isset_POST('clef_id'), $user->ID);
         $session = ClefSession::start();
         $session->set('clef_account_connected_on_login', true);
         $session->set('logged_in_at', time());
     }
     return $user;
 }
 public static function verify_state()
 {
     $request_state = ClefUtils::isset_GET('state') ? ClefUtils::isset_GET('state') : ClefUtils::isset_POST('state');
     $correct_state = ClefUtils::get_state();
     if ($request_state && $correct_state && $correct_state == $request_state) {
         ClefUtils::initialize_state(true);
         return true;
     } else {
         throw new ClefStateException('The state parameter is not verified. This may be due to this page being cached by another WordPress plugin. Please refresh your page and try again. If the issue persists, please follow <a href="http://support.getclef.com/article/95-the-state-parameter-is-not-verified-error#caching" target="_blank">this guide</a> to debug the issue.');
     }
 }