AuthenticationResult
You can supply two callback functions to the AuthenticationResult authenticated and notAuthenticated, each will be passed the KeycloakInstance.

Signature

1
{
2
auth: KeycloakInstance,
3
isAuthenticated: boolean,
4
authenticated: (onAuthenticated: (auth: KeycloakInstance) => void) => AuthenticationResult;
5
notAuthenticated: (onNotAuthenticated: (auth: KeycloakInstance) => void) => AuthenticationResult;
6
}
Copied!

Parameters

Parameter
Required
Description
authenticated
True
a callback function to be executed when the user is authenticated after the call.
notAuthenticated
True
a callback function to be executed when the user is not authenticated after the call.

Example

1
// Check if a user is authenticated.
2
venlyConnect.checkAuthenticated()
3
.then((result) => result.authenticated((auth) => {
4
console.log('The user is authenticated: ' + auth.subject);
5
})
6
.notAuthenticated((auth) => {
7
console.log('The user is not authenticated');
8
})
9
);
10
​
11
// Check if a user is authenticated. If not, show the login form
12
venlyConnect.authenticate()
13
.then((result) => result.authenticated((auth) => {
14
console.log('The user is authenticated: ' + auth.subject);
15
})
16
.notAuthenticated((auth) => {
17
console.log('The user is not authenticated');
18
})
19
);
Copied!
Last modified 2mo ago