public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function getInstance($settings) { if (!self::$instance) { self::$instance = new self($settings); } return self::$instance; }
/** * Handles determing if a redirect to the AAD signin experience is needed * * @since 0.2.1 * * @param int $user_id User ID * * @return null */ public function maybe_redirect_to_aad($user_id) { if (!isset($_GET['user_id_to_map'], $_GET['link-aadsso']) || $_GET['user_id_to_map'] != $user_id || !wp_verify_nonce($_GET['link-aadsso'], 'link-aadsso')) { return; } update_user_meta($user_id, 'is_aadsso_linking', 'true'); wp_redirect($this->aadsso->getLoginUrl()); exit; }
/** * Handles determining if redirects are needed * * @since 0.2.1 * * @return null */ public function handle_redirects() { global $pagenow; $user_id = get_current_user_id(); if (!isset($_GET['user_id_to_map']) || 'profile.php' != $pagenow || $_GET['user_id_to_map'] != $user_id) { return; } if (get_user_meta($user_id, 'aadsso_is_linked', 1)) { wp_redirect(admin_url('profile.php?aadsso_is_linked')); exit; } if (!isset($_GET['link-aadsso']) || !wp_verify_nonce($_GET['link-aadsso'], 'link-aadsso')) { return; } update_user_meta($user_id, 'is_aadsso_linking', 'true'); wp_redirect($this->aadsso->getLoginUrl()); exit; }
public static function getAccessTokenAsNativeApp($code, $settings) { // Construct the body for the access token request $authenticationRequestBody = http_build_query(array('grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => AADSSO::redirect_uri('request_access_token_as_native_app'), 'resource' => $settings->resourceURI, 'client_id' => $settings->client_id)); return self::getAndProcessAccessToken($authenticationRequestBody, $settings); }