Created
October 24, 2015 21:53
-
-
Save justingreerbbi/241ceb400b66606283da to your computer and use it in GitHub Desktop.
Only allow 1 access token session per client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Only allow 1 acces_token at a time | |
* @param [type] $results [description] | |
* @return [type] [description] | |
*/ | |
function test_only_allow_one_access_token ( $object ) { | |
if ( is_null( $object ) ) | |
return; | |
// Define the user ID | |
$user_id = $object['user_id']; | |
// Remove all other access tokens and refresh tokens from the system | |
global $wpdb; | |
$wpdb->delete( "{$wpdb->prefix}oauth_access_tokens", array( "user_id" => $user_id ) ); | |
$wpdb->delete( "{$wpdb->prefix}oauth_refresh_tokens", array( "user_id" => $user_id) ); | |
return; | |
} | |
add_action('wo_set_access_token', 'test_only_allow_one_access_token'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment