@licklist/design 0.78.5-dev.36 → 0.78.5-dev.37
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.
- package/dist/auth/Authorizer.d.ts.map +1 -1
- package/dist/auth/Authorizer.js +15 -11
- package/package.json +3 -3
- package/src/auth/Authorizer.tsx +23 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authorizer.d.ts","sourceRoot":"","sources":["../../src/auth/Authorizer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAA;AASnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;CACnC;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"Authorizer.d.ts","sourceRoot":"","sources":["../../src/auth/Authorizer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAA;AASnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;CACnC;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAqFzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/auth/Authorizer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
-
import { useLocation, matchPath } from 'react-router-dom';
|
|
3
|
+
import { useLocation, useNavigate, matchPath } from 'react-router-dom';
|
|
4
4
|
import useUser from '@licklist/plugins/dist/context/user/hooks/useUser';
|
|
5
5
|
import { MATCH_ROUTE_PATTERNS, ROUTES } from '@licklist/core/dist/Config';
|
|
6
6
|
import useAuthApi from '@licklist/plugins/dist/hooks/Api/useAuthApi';
|
|
@@ -72,6 +72,7 @@ function Authorizer(props) {
|
|
|
72
72
|
var user = useUser();
|
|
73
73
|
var useProfile = useAuthApi().useProfile;
|
|
74
74
|
var pathname = useLocation().pathname;
|
|
75
|
+
var navigate = useNavigate();
|
|
75
76
|
// This will re-fetch user's profile
|
|
76
77
|
var profile = useProfile();
|
|
77
78
|
var _useState = _sliced_to_array(useState(false), 2), isValidated = _useState[0], setIsValidated = _useState[1];
|
|
@@ -94,7 +95,7 @@ function Authorizer(props) {
|
|
|
94
95
|
});
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
var publicRoutes = [
|
|
98
99
|
ROUTES.LOGIN_PAGE,
|
|
99
100
|
ROUTES.REGISTER_PAGE,
|
|
100
101
|
ROUTES.PRIVACY_PAGE,
|
|
@@ -104,26 +105,29 @@ function Authorizer(props) {
|
|
|
104
105
|
ROUTES.FORGOT_PASSWORD,
|
|
105
106
|
ROUTES.SSO_LOGIN,
|
|
106
107
|
ROUTES.MAINTENANCE_PAGE
|
|
107
|
-
].concat(_to_consumable_array(matchedPathPatternUrls()))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
].concat(_to_consumable_array(matchedPathPatternUrls()));
|
|
109
|
+
// If we're on a public route (e.g. /login), mark as validated and never redirect
|
|
110
|
+
if (publicRoutes.includes(pathname)) {
|
|
111
|
+
setIsValidated(true);
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
114
|
var route = RouteService.getCurrentRoute();
|
|
114
|
-
|
|
115
|
-
ROUTES.
|
|
115
|
+
navigate([
|
|
116
|
+
ROUTES.LOGIN_PAGE,
|
|
116
117
|
"returnUrl=".concat(escape(route))
|
|
117
|
-
].join('?')
|
|
118
|
+
].join('?'), {
|
|
119
|
+
replace: true
|
|
120
|
+
});
|
|
118
121
|
}, [
|
|
119
122
|
auth.secrets,
|
|
120
123
|
user.profile,
|
|
121
124
|
profile.data,
|
|
122
|
-
matchedPathPatternUrls,
|
|
123
125
|
profile.isError,
|
|
124
126
|
profile.isLoading,
|
|
125
127
|
profile.isFetching,
|
|
126
|
-
pathname
|
|
128
|
+
pathname,
|
|
129
|
+
matchedPathPatternUrls,
|
|
130
|
+
navigate
|
|
127
131
|
]);
|
|
128
132
|
if (profile.isFetching || profile.isLoading || !isValidated) return /*#__PURE__*/ jsx(BlockLoader, {});
|
|
129
133
|
return /*#__PURE__*/ jsx(Fragment, {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@licklist/design",
|
|
3
|
-
"version": "0.78.5-dev.
|
|
3
|
+
"version": "0.78.5-dev.37",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "git+ssh://git@bitbucket.org/
|
|
6
|
+
"url": "git+ssh://git@bitbucket.org/bookedit-licklist/licklist_design.git"
|
|
7
7
|
},
|
|
8
8
|
"author": "Yaroslav Havryliv",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"homepage": "https://bitbucket.org/
|
|
11
|
+
"homepage": "https://bitbucket.org/bookedit-licklist/licklist_design#readme",
|
|
12
12
|
"description": "",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"start": "storybook dev -p 9009",
|
package/src/auth/Authorizer.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, useEffect, useState, useCallback } from 'react'
|
|
2
|
-
import { matchPath, useLocation } from 'react-router-dom'
|
|
2
|
+
import { matchPath, useLocation, useNavigate } from 'react-router-dom'
|
|
3
3
|
import useUser from '@licklist/plugins/dist/context/user/hooks/useUser'
|
|
4
4
|
import { ROUTES, MATCH_ROUTE_PATTERNS } from '@licklist/core/dist/Config'
|
|
5
5
|
import useAuthApi from '@licklist/plugins/dist/hooks/Api/useAuthApi'
|
|
@@ -18,6 +18,7 @@ function Authorizer(props: AuthorizerProps) {
|
|
|
18
18
|
const { useProfile } = useAuthApi()
|
|
19
19
|
|
|
20
20
|
const { pathname } = useLocation()
|
|
21
|
+
const navigate = useNavigate()
|
|
21
22
|
|
|
22
23
|
// This will re-fetch user's profile
|
|
23
24
|
const profile = useProfile()
|
|
@@ -54,38 +55,41 @@ function Authorizer(props: AuthorizerProps) {
|
|
|
54
55
|
return
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
|
|
58
|
+
const publicRoutes = [
|
|
59
|
+
ROUTES.LOGIN_PAGE,
|
|
60
|
+
ROUTES.REGISTER_PAGE,
|
|
61
|
+
ROUTES.PRIVACY_PAGE,
|
|
62
|
+
ROUTES.TERMS_PAGE,
|
|
63
|
+
ROUTES.PRIVACY_FACTS_PAGE,
|
|
64
|
+
ROUTES.CHANGE_PASSWORD,
|
|
65
|
+
ROUTES.FORGOT_PASSWORD,
|
|
66
|
+
ROUTES.SSO_LOGIN,
|
|
67
|
+
ROUTES.MAINTENANCE_PAGE,
|
|
68
|
+
...matchedPathPatternUrls(),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
// If we're on a public route (e.g. /login), mark as validated and never redirect
|
|
72
|
+
if (publicRoutes.includes(pathname)) {
|
|
73
|
+
setIsValidated(true)
|
|
72
74
|
return
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
const route = RouteService.getCurrentRoute()
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
[ROUTES.
|
|
79
|
+
navigate(
|
|
80
|
+
[ROUTES.LOGIN_PAGE, `returnUrl=${escape(route)}`].join('?'),
|
|
81
|
+
{ replace: true },
|
|
79
82
|
)
|
|
80
83
|
}, [
|
|
81
84
|
auth.secrets,
|
|
82
85
|
user.profile,
|
|
83
86
|
profile.data,
|
|
84
|
-
matchedPathPatternUrls,
|
|
85
87
|
profile.isError,
|
|
86
88
|
profile.isLoading,
|
|
87
89
|
profile.isFetching,
|
|
88
90
|
pathname,
|
|
91
|
+
matchedPathPatternUrls,
|
|
92
|
+
navigate,
|
|
89
93
|
])
|
|
90
94
|
|
|
91
95
|
if (profile.isFetching || profile.isLoading || !isValidated)
|