@servicetitan/docs-uikit 33.0.1 → 33.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,5 +8,6 @@ title: AJAX Handlers
|
|
|
8
8
|
|
|
9
9
|
## API
|
|
10
10
|
|
|
11
|
-
- [withMicroservice](./with-microservice.mdx) - Use
|
|
12
|
-
- [
|
|
11
|
+
- [withMicroservice](./with-microservice.mdx) - Use to wrap components and authenticate requests to protected resources with support for Bearer and Token Server authentication.
|
|
12
|
+
- [initAjaxHandlersLoginRequired](./init-ajax-handlers-login-required.mdx) - Use to register handler for invalid TokenServer session.
|
|
13
|
+
- [initAjaxHandlersParseDates](./init-ajax-handlers-parse-dates.mdx) - Use to automatically transform date strings in axios responses into JavaScript Date objects.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: initAjaxHandlersLoginRequired
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`initAjaxHandlersLoginRequired` registers a function that handles when a TokenServer session is not valid and the current application session must be terminated and the user forced to login again.
|
|
6
|
+
|
|
7
|
+
It sometimes happens that a user's application session is active but their authentication cookie on the TokenServer domain is missing, due to manual deletion, browser cleanup, etc. When this occurs, the TokenServer silent login fails and, because the main application session is active, reloading the page doesn't force the user to (re)login and get a valid TokenServer cookie.
|
|
8
|
+
|
|
9
|
+
Use `initAjaxHandlersLoginRequired` to detect when this happens and force the user to login again.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Call this function once in your application's initialization code, before loading any MFEs.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { initAjaxHandlersLoginRequired } from '@servicetitan/ajax-handlers';
|
|
17
|
+
|
|
18
|
+
// Register handler for "login required" scenario
|
|
19
|
+
|
|
20
|
+
initAjaxHandlersLoginRequired(() => {
|
|
21
|
+
window.location.assign('/#/Auth/Logout');
|
|
22
|
+
});
|
|
23
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-uikit",
|
|
3
|
-
"version": "33.
|
|
3
|
+
"version": "33.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"cli": {
|
|
17
17
|
"webpack": false
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "36ff4078b07d6c86bdf968b7f8b3c0adbe03fd4c"
|
|
20
20
|
}
|