Skip to content

Commit 56a3b81

Browse files
committed
Force reauthentication on init
1 parent c9e4633 commit 56a3b81

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

oauth-server.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ function json_oauth_load() {
6161
}
6262
add_action( 'init', 'json_oauth_load' );
6363

64+
/**
65+
* Force reauthentication after we've registered our handler
66+
*
67+
* We could have checked authentication before OAuth was loaded. If so, let's
68+
* try and reauthenticate now that OAuth is loaded.
69+
*/
70+
function json_oauth_force_reauthentication() {
71+
if ( is_user_logged_in() ) {
72+
// Another handler has already worked successfully, no need to
73+
// reauthenticate.
74+
75+
return;
76+
}
77+
78+
// Force reauthentication
79+
global $current_user;
80+
$current_user = null;
81+
get_currentuserinfo();
82+
}
83+
add_action( 'init', 'json_oauth_force_reauthentication', 100 );
84+
6485
/**
6586
* Load the JSON API
6687
*/

0 commit comments

Comments
 (0)