1

I'm developing a login plugin and need to test the login form that pops up after a session has expired.

I would like to see the popup appear on my request. Any hack is fine. Ideally some little javascript to run from the console.

2 Answers 2

5

I've discovered the following stuff.

This kind of login is called internally Interim. It works thanks to the continuous polling offered by the Heartbeat API. The prefix of the expired session functionality is wp-auth-check and the important bit for me was a little script at /wp-includes/js/wp-auth-check.js.

When the auth check request is sent to the server, the response will contain a true if the session is active or a false if it has expired. Based on that, the script decides if it has to show the modal login or not. Given that all is managed by events, it is sufficient to trigger one like this

jQuery(document).trigger('heartbeat-tick.wp-auth-check', [ {'wp-auth-check': false} ])

to make the dialog box appear.

0
0

Thanks to @Ando answer. But in my case, it is not work correctly.

When I run the script, the popup modal shows but it hides itself in few seconds. I think maybe the session is not truly expired. So I try to figure it out how to do this trick.

And I found was: just append param reauth to 1 as followings:

var authCheckForm = jQuery("#wp-auth-check-form");
var originSrc = authCheckForm.data("src");
authCheckForm.data("src", originSrc + "&reauth=1");

And then run the script: (by @Ando answer)

jQuery(document).trigger('heartbeat-tick.wp-auth-check', [ {'wp-auth-check': false} ]);

Its works for me. Hope it helps to others. :-)

Ps. test in 4.3.5 version.

Not the answer you're looking for? Browse other questions tagged or ask your own question.