Slack_Helpers::capture_oauth_tokens()

Captures the OAuthentication tokens.


Return Return

(Uncanny_Automatorvoid.)


Source Source

File: src/integrations/slack/helpers/slack-helpers.php

	public function capture_oauth_tokens() {
		if ( isset( $_REQUEST['tab'] ) && $this->setting_tab == $_REQUEST['tab'] ) {

			if ( ! empty( $_GET['automator_api_message'] ) ) {
				$tokens = Automator_Helpers_Recipe::automator_api_decode_message( $_GET['automator_api_message'], wp_create_nonce( 'automator_slack_api_authentication' ) );

				if ( $tokens ) {
					update_option( '_uncannyowl_slack_settings', $tokens );
					wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab . '&connect=1' ) );
					die;
				} else {
					wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab . '&connect=2' ) );
					die;
				}
			} elseif ( ! empty( $_GET['disconnect'] ) ) {
				delete_option( '_uncannyowl_slack_settings' );
				wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab ) );
				die;
			}
		}
	}