Get User Login Status
Typically, an enterprise has multiple website systems. For a better user experience, after a user logs in and authenticates on the first website application, when accessing the homepage of the second/nth website application in the same browser, it is desired to know the current user's login status in advance by calling the IDaaS interface via an Ajax request. If the user is already logged in, they can directly log into the second/nth website without needing to manually click the login button to trigger the single sign-on process.
# Request Description
GET https://{domain_name}/api/v1/config/isLogin
# Request Headers
| Parameter Name | Chinese Name | Required | Type | Description |
|---|---|---|---|---|
| Cookie | SSO Cookie | Yes | String | Example: AMS_SID=abcde-123, automatically sent by the browser with cookies |
# Request Example
Ajax request code example:
$.ajax({
url: "https://{your_domain}/api/v1/config/isLogin",
type: "get",
dataType: 'json',
xhrFields: {
withCredentials: true // Ajax request carries cross-domain cookies
},
success(data) {
console.info(data);
},
error(err) {
console.log(err);
}
});
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Request Parameters
None
# Response Example
Example for user logged-in status:
HTTP/1.1 200 OK
Content-Type: application/json
true
Example for user not logged-in status:
HTTP/1.1 200 OK
Content-Type: application/json
false
2
3
4
5
6
7
8
9
10
11
12
# Response Parameters
true: indicates the user is logged in.
false: indicates the user is not logged in.
# Notes
Since the interface for obtaining user login status is a front-end interface, calling it from the front-end involves two scenarios: cross-origin and cross-site.
In cross-origin/cross-domain scenarios, it is necessary to set up a whitelist of allowed cross-domain domain addresses in the enterprise center.
In cross-site scenarios, Safari browser currently defaults to enabling "Prevent cross-site tracking," which blocks access to third-party cookies across sites. The solution is to customize the IDaaS domain to the enterprise's own domain, thereby changing the cross-site scenario to a same-site scenario.
