forceLogout

t[ Function ]

public static forceLogout(
    username: string | TcHmi.Server.IForceLogoutTarget | null | undefined,
    callback?: null | (
        (data: TcHmi.IResultObject) => void
    ) = null
): boolean;

Logs out any user if the appropriate user privileges are available.

Parameter

Name

Type

Description

username

string, TcHmi.Server.IForceLogoutTarget, null, undefined,

The name of the user to be logged out.

If an empty string or null is passed, all users of the server are logged out.

From version 1.10.1172.0:
The authentication domain can be added as name: 'Domain::UserName'. If only the authentication domain is specified, all users of this domain will be logged out.

Alternatively, an object can be passed that specifies conditions for a user to log out.

callback [ optional ]

(data: TcHmi.IResultObject) => void

Asynchronous callback function that is triggered when the operation was terminated.

Return value

Type

Description

boolean

Returns confirmation as to whether the operation was successfully sent.

forceLogout 1:

Available from 1.8

forceLogout 2:

Up to version 1.10.1172.0 only string and null were allowed as userName.

Sample - JavaScript

// Logout a user with this name in all authenfication domains
TcHmi.Server.forceLogout('johnDoe', function(data) {
    if (data.error === TcHmi.Errors.NONE) {
        // Success
    } else {
        // Error
    }
});

From version 1.10.1172.0

// Logout johnDoe from the authenfication domain TcHmiUserManagement
TcHmi.Server.forceLogout(
    'TcHmiUserManagement::johnDoe',
    function(data) {
        if (data.error === TcHmi.Errors.NONE) {
            // Success
        } else {
            // Error
        }
    }
);
// Logout all users from this authenfication domain
TcHmi.Server.forceLogout(
    'TcHmiUserManagement::',
    function(data) {
        if (data.error === TcHmi.Errors.NONE) {
            // Success
        } else {
            // Error
        }
    }
);
// Logout all users which matches ONE of the conditions:
// IP: 127.0.0.1 (as seen from the server)
// clientCertificate with this fingerprint/thumbprint
// member of the group 'SystemAdministrator'
TcHmi.Server.forceLogout(
    {
        clientIp: '127.0.0.1',
        clientCertificate: '8e810e91d365662783480d0e4f54f9e037bc1157c9f5634a36bbcc096530dd960f66e5a072d069b5c8dce66bb633166131b8ad49467d27a93cd72cd96f346a80',
        group: 'SystemAdministrator'
    },
    function(data) {
        if (data.error === TcHmi.Errors.NONE) {
            // Success
        } else {
            // Error
        }
    }
);