Expand all

mediawiki.authenticationPopup

Exposes an instance of AuthPopup configured to display a login dialog for the local instance of MediaWiki.

The promises returned by AuthPopup methods will be resolved with a mediawiki.authenticationPopup~userinfo object.

For security-sensitive reauthentication (an already-logged-in user re-entering credentials to elevate their session security level for a specific operation), use forReauthentication() instead of the default login instance.

This library is not stable yet (as of May 2024). We're still testing which of the methods work from the technical side, and which methods are understandable for users. Some methods or the whole library may be removed in the future.

Examples

const authPopup = require( 'mediawiki.authenticationPopup' );
authPopup.startPopupWindow()
// or: authPopup.startNewTabOrWindow()
// or: authPopup.startIframe()
    .then( function ( userinfo ) {
        if ( userinfo ) {
            // Logged in
            console.log( userinfo.name );
        } else {
            // Cancelled by the user
        }
    }, function ( error ) {
        // Unexpected error stopped the login process
    } );

Reauthentication for a security-sensitive operation

const authPopup = require( 'mediawiki.authenticationPopup' );
const ok = await authPopup.forReauthentication( 'edit' ).startPopupWindow();
if ( ok ) {
    // Reauthenticated: the operation no longer requires reauth (SEC_OK)
} else {
    // Cancelled by the user
}
Source:

Methods

loginPopup.forReauthentication(operation) → {AuthPopup}static #

Build an AuthPopup that performs a security-sensitive reauthentication for the given operation, rather than a fresh login.

Parameters:

Name Type Description
operation string

Security-sensitive operation name (the force value)

Returns:

Type
AuthPopup
Source:

Build an AuthPopup that performs a security-sensitive reauthentication for the given operation, rather than a fresh login.

Type Definitions

userinfo #

userinfo object as returned by the action=query&meta=userinfo API module.

Type:

Properties:

Name Type Description
name string
id number
Source:

userinfo object as returned by the action=query&meta=userinfo API module.