@rpcbase/client 0.174.0 → 0.175.0
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/auth/{AccountsList → components/AccountsList}/AccountListItem.js +3 -8
- package/auth/{AccountsList → components/AccountsList}/index.js +2 -4
- package/auth/{Footer.js → components/Footer/index.js} +1 -4
- package/auth/{ForgotPassword → components/ForgotPassword}/index.js +3 -6
- package/auth/{SetNewPassword → components/SetNewPassword}/index.js +3 -11
- package/auth/{SignIn → components/SignIn}/SignInEmailForm.js +7 -9
- package/auth/{SignIn → components/SignIn}/index.js +4 -6
- package/auth/{SignOut → components/SignOut}/index.js +8 -12
- package/auth/{SignUp → components/SignUp}/SignUpEmailForm.js +7 -9
- package/auth/{SignUp → components/SignUp}/index.js +4 -6
- package/auth/helpers/{redirect_sign_in.native.js → redirectSignIn.native.js} +1 -3
- package/auth/helpers/{redirect_sign_in.web.js → redirectSignIn.web.js} +1 -3
- package/auth/index.js +39 -39
- package/auth/{sign_out.js → signOut.js} +4 -4
- package/auth/useAuthRouter.js +5 -5
- package/package.json +1 -1
- /package/auth/{AccountsList → components/AccountsList}/account-list-item.scss +0 -0
- /package/auth/{ForgotPassword → components/ForgotPassword}/forgot-password.scss +0 -0
- /package/auth/{SetNewPassword → components/SetNewPassword}/set-new-password.scss +0 -0
- /package/auth/{SignIn → components/SignIn}/sign-in.scss +0 -0
- /package/auth/{SignOut → components/SignOut}/sign-out.scss +0 -0
- /package/auth/{SignUp → components/SignUp}/sign-up.scss +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import page from "../../page"
|
|
5
|
-
import getInitials from "../../helpers/getInitials"
|
|
6
|
-
import Avatar from "../../ui/Avatar"
|
|
2
|
+
import getInitials from "../../../helpers/getInitials"
|
|
3
|
+
import Avatar from "../../../ui/Avatar"
|
|
7
4
|
|
|
8
5
|
import "./account-list-item.scss"
|
|
9
6
|
|
|
@@ -47,7 +44,7 @@ const getUserName = (user) => {
|
|
|
47
44
|
return name
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
const AccountListItem = ({account, onClick, avatarProps}) => {
|
|
47
|
+
export const AccountListItem = ({account, onClick, avatarProps}) => {
|
|
51
48
|
|
|
52
49
|
return (
|
|
53
50
|
<div
|
|
@@ -62,5 +59,3 @@ const AccountListItem = ({account, onClick, avatarProps}) => {
|
|
|
62
59
|
</div>
|
|
63
60
|
)
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
export default AccountListItem
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import AccountListItem from "./AccountListItem"
|
|
2
|
+
import {AccountListItem} from "./AccountListItem"
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const AccountsList = ({accounts}) => {
|
|
5
|
+
export const AccountsList = ({accounts}) => {
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
8
|
<>
|
|
@@ -15,5 +15,3 @@ const AccountsList = ({accounts}) => {
|
|
|
15
15
|
</>
|
|
16
16
|
)
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
export default AccountsList
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
|
|
3
2
|
const year = (new Date).getFullYear()
|
|
4
3
|
|
|
5
|
-
const Footer = ({name}) => {
|
|
4
|
+
export const Footer = ({name}) => {
|
|
6
5
|
|
|
7
6
|
return (
|
|
8
7
|
<footer className="pt-5 my-5 text-muted border-top">
|
|
@@ -10,5 +9,3 @@ const Footer = ({name}) => {
|
|
|
10
9
|
</footer>
|
|
11
10
|
)
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
export default Footer
|
|
@@ -4,14 +4,13 @@ import {useHash} from "react-use"
|
|
|
4
4
|
import {ActivityIndicator} from "react-native"
|
|
5
5
|
import isEmail from "validator/lib/isEmail"
|
|
6
6
|
|
|
7
|
-
import post from "
|
|
7
|
+
import post from "../../../helpers/post"
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import Footer from "../Footer"
|
|
9
|
+
import {Footer} from "../Footer"
|
|
11
10
|
|
|
12
11
|
import "./forgot-password.scss"
|
|
13
12
|
|
|
14
|
-
const ForgotPassword = ({name, logo}) => {
|
|
13
|
+
export const ForgotPassword = ({name, logo}) => {
|
|
15
14
|
const [hash, setHash] = useHash()
|
|
16
15
|
|
|
17
16
|
const [isLoading, setIsLoading] = useState(false)
|
|
@@ -113,5 +112,3 @@ const ForgotPassword = ({name, logo}) => {
|
|
|
113
112
|
</div>
|
|
114
113
|
)
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
export default ForgotPassword
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
import {useState, useEffect} from "react"
|
|
3
3
|
import {useSearchParam} from "react-use"
|
|
4
4
|
import {ActivityIndicator} from "react-native"
|
|
5
|
-
import isEmail from "validator/lib/isEmail"
|
|
6
5
|
|
|
7
|
-
import post from "
|
|
6
|
+
import post from "../../../helpers/post"
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import Footer from "../Footer"
|
|
8
|
+
import {Footer} from "../Footer"
|
|
11
9
|
|
|
12
10
|
import "./set-new-password.scss"
|
|
13
11
|
|
|
14
|
-
const SetNewPassword = ({name, logo}) => {
|
|
12
|
+
export const SetNewPassword = ({name, logo}) => {
|
|
15
13
|
const [isLoading, setIsLoading] = useState(false)
|
|
16
14
|
const [error, setError] = useState()
|
|
17
15
|
const [isSuccess, setIsSuccess] = useState(false)
|
|
@@ -22,10 +20,6 @@ const SetNewPassword = ({name, logo}) => {
|
|
|
22
20
|
const user_id = useSearchParam("uid")
|
|
23
21
|
const token = useSearchParam("token")
|
|
24
22
|
|
|
25
|
-
// useEffect(() => {
|
|
26
|
-
// console.log("TOKEN", user_id, token)
|
|
27
|
-
// }, [user_id, token])
|
|
28
|
-
|
|
29
23
|
const onSubmit = async(e) => {
|
|
30
24
|
e.preventDefault()
|
|
31
25
|
|
|
@@ -134,5 +128,3 @@ const SetNewPassword = ({name, logo}) => {
|
|
|
134
128
|
</div>
|
|
135
129
|
)
|
|
136
130
|
}
|
|
137
|
-
|
|
138
|
-
export default SetNewPassword
|
|
@@ -5,15 +5,15 @@ import {useState, useEffect} from "react"
|
|
|
5
5
|
import useSearchParam from "react-use/lib/useSearchParam"
|
|
6
6
|
import isEmail from "validator/lib/isEmail"
|
|
7
7
|
|
|
8
|
-
import page from "
|
|
9
|
-
import post from "
|
|
10
|
-
import {reconnect as rts_reconnect} from "
|
|
11
|
-
import {
|
|
8
|
+
import page from "../../../page"
|
|
9
|
+
import post from "../../../helpers/post"
|
|
10
|
+
import {reconnect as rts_reconnect} from "../../../rts/rts"
|
|
11
|
+
import {setIsSignedIn, setUid, setTenantId} from "../../index"
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
const log = debug("rb:auth:signin")
|
|
15
15
|
|
|
16
|
-
const SignInEmailForm = ({onSuccess, onSuccessRedirect}) => {
|
|
16
|
+
export const SignInEmailForm = ({onSuccess, onSuccessRedirect}) => {
|
|
17
17
|
const redirect = useSearchParam("redirect")
|
|
18
18
|
|
|
19
19
|
const [isLoading, setIsLoading] = useState(false)
|
|
@@ -47,8 +47,8 @@ const SignInEmailForm = ({onSuccess, onSuccessRedirect}) => {
|
|
|
47
47
|
|
|
48
48
|
setUid(user_id)
|
|
49
49
|
const tenantId = user_id.slice(8, 16)
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
setTenantId(tenantId)
|
|
51
|
+
setIsSignedIn(true)
|
|
52
52
|
|
|
53
53
|
// we must now reconnect on the websocket as we now have a new cookie
|
|
54
54
|
rts_reconnect(tenantId)
|
|
@@ -111,5 +111,3 @@ const SignInEmailForm = ({onSuccess, onSuccessRedirect}) => {
|
|
|
111
111
|
</form>
|
|
112
112
|
)
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
export default SignInEmailForm
|
|
@@ -3,10 +3,10 @@ import assert from "assert"
|
|
|
3
3
|
|
|
4
4
|
import authConfig from "@rpcbase/dot-rb/auth"
|
|
5
5
|
|
|
6
|
-
import {AUTH_BUTTONS} from "
|
|
7
|
-
import Footer from "../Footer"
|
|
6
|
+
import {AUTH_BUTTONS} from "../../../src/ui/oauth"
|
|
7
|
+
import {Footer} from "../Footer"
|
|
8
8
|
|
|
9
|
-
import SignInEmailForm from "./SignInEmailForm"
|
|
9
|
+
import {SignInEmailForm} from "./SignInEmailForm"
|
|
10
10
|
|
|
11
11
|
import "./sign-in.scss"
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ import "./sign-in.scss"
|
|
|
14
14
|
const hasOAuth = authConfig.oauth_providers?.length > 0
|
|
15
15
|
const hasEmail = authConfig.has_email_signup
|
|
16
16
|
|
|
17
|
-
const SignIn = ({
|
|
17
|
+
export const SignIn = ({
|
|
18
18
|
name,
|
|
19
19
|
logo,
|
|
20
20
|
onSuccessRedirect = "/",
|
|
@@ -66,5 +66,3 @@ const SignIn = ({
|
|
|
66
66
|
</div>
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
export default SignIn
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import assert from "assert"
|
|
3
3
|
import {useState, useEffect} from "react"
|
|
4
|
-
import {ActivityIndicator} from "react-native"
|
|
5
4
|
import Alert from "react-bootstrap/Alert"
|
|
6
5
|
|
|
7
6
|
import authConfig from "@rpcbase/dot-rb/auth"
|
|
8
7
|
|
|
9
|
-
import
|
|
10
|
-
import {sign_out} from "../sign_out"
|
|
8
|
+
import {signOut} from "../../signOut"
|
|
11
9
|
|
|
12
|
-
import post from "
|
|
10
|
+
import post from "../../../helpers/post"
|
|
13
11
|
|
|
14
|
-
import AccountListItem from "../AccountsList/AccountListItem"
|
|
15
|
-
import Footer from "../Footer"
|
|
12
|
+
import {AccountListItem} from "../AccountsList/AccountListItem"
|
|
13
|
+
import {Footer} from "../Footer"
|
|
16
14
|
|
|
17
15
|
import "./sign-out.scss"
|
|
18
16
|
|
|
@@ -20,7 +18,7 @@ import "./sign-out.scss"
|
|
|
20
18
|
// TODO: clear cache + db
|
|
21
19
|
const hasMultiAccounts = authConfig.has_multi_accounts
|
|
22
20
|
|
|
23
|
-
const SignOut = ({
|
|
21
|
+
export const SignOut = ({
|
|
24
22
|
logo,
|
|
25
23
|
name,
|
|
26
24
|
onSignOutSuccess = () => null
|
|
@@ -45,11 +43,11 @@ const SignOut = ({
|
|
|
45
43
|
}, [])
|
|
46
44
|
|
|
47
45
|
|
|
48
|
-
const
|
|
46
|
+
const onSignOut = async() => {
|
|
49
47
|
// TODO: NYI handle sign out from multiple accounts here
|
|
50
48
|
const res = await post("/api/v1/auth/sign_out")
|
|
51
49
|
if (res.status === "ok") {
|
|
52
|
-
|
|
50
|
+
signOut()
|
|
53
51
|
setIsSignedOut(true)
|
|
54
52
|
onSignOutSuccess()
|
|
55
53
|
} else {
|
|
@@ -60,7 +58,7 @@ const SignOut = ({
|
|
|
60
58
|
|
|
61
59
|
const onSubmit = () => {
|
|
62
60
|
console.log("sign out from selected accounts", selectedAccounts)
|
|
63
|
-
|
|
61
|
+
onSignOut()
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
const message = hasMultiAccounts ? "Select accounts to sign out of:" : "Click here to sign out of your account:"
|
|
@@ -134,5 +132,3 @@ const SignOut = ({
|
|
|
134
132
|
</div>
|
|
135
133
|
)
|
|
136
134
|
}
|
|
137
|
-
|
|
138
|
-
export default SignOut
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import {useState} from "react"
|
|
3
3
|
|
|
4
|
-
import page from "
|
|
5
|
-
import {reconnect as rts_reconnect} from "
|
|
4
|
+
import page from "../../../page"
|
|
5
|
+
import {reconnect as rts_reconnect} from "../../../rts/rts"
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import post from "
|
|
7
|
+
import {setIsSignedIn, setUid, setTenantId} from "../../index"
|
|
8
|
+
import post from "../../../helpers/post"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const SignUpEmailForm = ({onSuccessRedirect, onSuccess}) => {
|
|
11
|
+
export const SignUpEmailForm = ({onSuccessRedirect, onSuccess}) => {
|
|
12
12
|
const [email, setEmail] = useState("")
|
|
13
13
|
const [password, setPassword] = useState("")
|
|
14
14
|
const [passwordConfirm, setPasswordConfirm] = useState("")
|
|
@@ -27,8 +27,8 @@ const SignUpEmailForm = ({onSuccessRedirect, onSuccess}) => {
|
|
|
27
27
|
setUid(user_id)
|
|
28
28
|
|
|
29
29
|
const tenantId = user_id.slice(8, 16)
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
setTenantId(tenantId)
|
|
31
|
+
setIsSignedIn(true)
|
|
32
32
|
|
|
33
33
|
// we must now reconnect on the websocket as we have a new cookie
|
|
34
34
|
rts_reconnect(tenantId)
|
|
@@ -97,5 +97,3 @@ const SignUpEmailForm = ({onSuccessRedirect, onSuccess}) => {
|
|
|
97
97
|
</>
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
export default SignUpEmailForm
|
|
@@ -3,11 +3,11 @@ import assert from "assert"
|
|
|
3
3
|
|
|
4
4
|
import authConfig from "@rpcbase/dot-rb/auth"
|
|
5
5
|
|
|
6
|
-
import {AUTH_BUTTONS} from "
|
|
6
|
+
import {AUTH_BUTTONS} from "../../../src/ui/oauth"
|
|
7
7
|
|
|
8
|
-
import Footer from "../Footer"
|
|
8
|
+
import {Footer} from "../Footer"
|
|
9
9
|
|
|
10
|
-
import SignUpEmailForm from "./SignUpEmailForm"
|
|
10
|
+
import {SignUpEmailForm} from "./SignUpEmailForm"
|
|
11
11
|
|
|
12
12
|
import "./sign-up.scss"
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ import "./sign-up.scss"
|
|
|
15
15
|
const hasOAuth = authConfig.oauth_providers?.length > 0
|
|
16
16
|
const hasEmail = authConfig.has_email_signup
|
|
17
17
|
|
|
18
|
-
const SignUp = ({
|
|
18
|
+
export const SignUp = ({
|
|
19
19
|
logo,
|
|
20
20
|
name,
|
|
21
21
|
onSuccessRedirect = "/",
|
|
@@ -64,5 +64,3 @@ const SignUp = ({
|
|
|
64
64
|
</div>
|
|
65
65
|
)
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
export default SignUp
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
export const redirectSignIn = (ctx) => {
|
|
4
4
|
console.log("REDIRECT SIGN IN NYI NATIVE")
|
|
5
5
|
console.log("CTX", ctx)
|
|
6
6
|
|
|
7
7
|
// const redirect_path = ctx.canonicalPath
|
|
8
8
|
// page.redirect(`/signin?redirect=${encodeURIComponent(redirect_path)}`)
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
export default redirect_sign_in
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import page from "../../page"
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
export const redirectSignIn = (ctx) => {
|
|
5
5
|
const redirect_path = ctx.canonicalPath
|
|
6
6
|
page.redirect(`/signin?redirect=${encodeURIComponent(redirect_path)}`)
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
export default redirect_sign_in
|
package/auth/index.js
CHANGED
|
@@ -4,26 +4,26 @@ import {Platform} from "react-native"
|
|
|
4
4
|
import isHexadecimal from "validator/lib/isHexadecimal"
|
|
5
5
|
|
|
6
6
|
import storage from "../storage"
|
|
7
|
-
import {disconnect as
|
|
7
|
+
import {disconnect as rtsDisconnect} from "../rts/rts"
|
|
8
8
|
import post from "../helpers/post"
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import {redirectSignIn} from "./helpers/redirectSignIn"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
const LAST_TENANT_KEY = "rb.last_tenant_id"
|
|
14
|
-
const
|
|
14
|
+
const uidStorageKey = (tenant_id) => `rb.${tenant_id}.user_id`
|
|
15
15
|
|
|
16
16
|
const log = debug("rb:auth")
|
|
17
17
|
|
|
18
18
|
// TODO: this should be refactored to AuthContext + Provider
|
|
19
19
|
|
|
20
|
-
let
|
|
20
|
+
let __isAuthenticated = null
|
|
21
21
|
|
|
22
|
-
let
|
|
23
|
-
let
|
|
22
|
+
let __tenantId = typeof storage !== "undefined" && storage.getItem(LAST_TENANT_KEY)
|
|
23
|
+
let __userId = typeof storage !== "undefined" && __tenantId && storage.getItem(uidStorageKey(__tenantId))
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const getQueryStringAuthId = () => {
|
|
27
27
|
const url = new URL(window.location.href)
|
|
28
28
|
const val = url.searchParams.get("auth_id")
|
|
29
29
|
if (!val) return null
|
|
@@ -34,14 +34,14 @@ const get_querystring_auth_id = () => {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const runSessionCheck = async() => {
|
|
38
38
|
// TODO: TMP: we're skipping the session check on mobile for now,
|
|
39
39
|
// this assumes having a token on mobile means we're authenticated
|
|
40
40
|
if (Platform.OS !== "web") {
|
|
41
41
|
return
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const auth_user_id =
|
|
44
|
+
const auth_user_id = getQueryStringAuthId()
|
|
45
45
|
|
|
46
46
|
if (auth_user_id) {
|
|
47
47
|
log("check_session with auth user_id", auth_user_id)
|
|
@@ -51,27 +51,27 @@ const run_session_check = async() => {
|
|
|
51
51
|
|
|
52
52
|
log("check_session response", res)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
__isAuthenticated = res.is_signed_in
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
// if not authenticated, clear
|
|
58
|
-
if (!
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
// if not authenticated, clear __userId + __tenantId and disconnect socket
|
|
58
|
+
if (!__isAuthenticated) {
|
|
59
|
+
__userId = null
|
|
60
|
+
__tenantId = null
|
|
61
|
+
rtsDisconnect()
|
|
62
62
|
return
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
__userId = res.user_id
|
|
66
|
+
__tenantId = __userId.slice(8, 16)
|
|
67
67
|
|
|
68
68
|
// save tenant id
|
|
69
|
-
if (
|
|
70
|
-
storage.setItem(LAST_TENANT_KEY,
|
|
69
|
+
if (__tenantId) {
|
|
70
|
+
storage.setItem(LAST_TENANT_KEY, __tenantId)
|
|
71
71
|
|
|
72
72
|
// cache user_id in storage
|
|
73
|
-
if (
|
|
74
|
-
storage.setItem(
|
|
73
|
+
if (__userId) {
|
|
74
|
+
storage.setItem(uidStorageKey(__tenantId), __userId)
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -79,54 +79,54 @@ const run_session_check = async() => {
|
|
|
79
79
|
|
|
80
80
|
// Force trigger run first session check (when we are not in a webworker (or mobile))
|
|
81
81
|
const isJest = !!process?.env?.JEST_WORKER_ID
|
|
82
|
-
if (typeof window !== "undefined" && !isJest)
|
|
82
|
+
if (typeof window !== "undefined" && !isJest) runSessionCheck()
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
export const
|
|
86
|
-
log("session_restrict:
|
|
85
|
+
export const getSessionRestrictMiddleware = () => (ctx, next) => {
|
|
86
|
+
log("session_restrict:__isAuthenticated", __isAuthenticated)
|
|
87
87
|
|
|
88
|
-
if (typeof
|
|
88
|
+
if (typeof __isAuthenticated !== "boolean") {
|
|
89
89
|
log("session_restrict: will run session check")
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
runSessionCheck()
|
|
92
92
|
.then(() => {
|
|
93
|
-
if (
|
|
93
|
+
if (__isAuthenticated) {
|
|
94
94
|
next()
|
|
95
95
|
} else {
|
|
96
|
-
|
|
96
|
+
redirectSignIn(ctx)
|
|
97
97
|
}
|
|
98
98
|
})
|
|
99
99
|
.catch((err) => {
|
|
100
100
|
console.log("warning error in check session request", err)
|
|
101
101
|
throw err
|
|
102
102
|
})
|
|
103
|
-
} else if (
|
|
103
|
+
} else if (__isAuthenticated) {
|
|
104
104
|
next()
|
|
105
105
|
} else {
|
|
106
|
-
log("AUTH", JSON.stringify(
|
|
106
|
+
log("AUTH", JSON.stringify(__isAuthenticated))
|
|
107
107
|
log("NOT AUTHENTICATED, REDIRECT HERE")
|
|
108
|
-
|
|
108
|
+
redirectSignIn(ctx)
|
|
109
109
|
// next()
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
export const privateGetUid = () =>
|
|
114
|
+
export const privateGetUid = () => __userId
|
|
115
115
|
export const setUid = (val) => {
|
|
116
|
-
|
|
116
|
+
__userId = val
|
|
117
117
|
|
|
118
118
|
if (typeof val === "string") {
|
|
119
119
|
const tenant_id_prefix = val.slice(8, 16)
|
|
120
|
-
storage.setItem(
|
|
120
|
+
storage.setItem(uidStorageKey(tenant_id_prefix), val)
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
export const getTenantId = () =>
|
|
125
|
-
export const
|
|
126
|
-
|
|
124
|
+
export const getTenantId = () => __tenantId
|
|
125
|
+
export const setTenantId = (val) => {
|
|
126
|
+
__tenantId = val
|
|
127
127
|
storage.setItem(LAST_TENANT_KEY, val)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
export const
|
|
130
|
+
export const setIsSignedIn = (val) => __isAuthenticated = val
|
|
131
131
|
|
|
132
|
-
export const
|
|
132
|
+
export const getIsSignedIn = () => __isAuthenticated
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import {
|
|
2
|
+
import {setIsSignedIn, setUid, setTenantId} from "./index"
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const signOut = () => {
|
|
5
5
|
setUid(null)
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
setTenantId(null)
|
|
7
|
+
setIsSignedIn(false)
|
|
8
8
|
localStorage.clear()
|
|
9
9
|
|
|
10
10
|
// TODO: clear DB
|
package/auth/useAuthRouter.js
CHANGED
|
@@ -2,11 +2,11 @@ import {useState} from "react"
|
|
|
2
2
|
|
|
3
3
|
import page from "../page"
|
|
4
4
|
|
|
5
|
-
import SignIn from "./SignIn"
|
|
6
|
-
import SignUp from "./SignUp"
|
|
7
|
-
import SignOut from "./SignOut"
|
|
8
|
-
import ForgotPassword from "./ForgotPassword"
|
|
9
|
-
import SetNewPassword from "./SetNewPassword"
|
|
5
|
+
import {SignIn} from "./components/SignIn"
|
|
6
|
+
import {SignUp} from "./components/SignUp"
|
|
7
|
+
import {SignOut} from "./components/SignOut"
|
|
8
|
+
import {ForgotPassword} from "./components/ForgotPassword"
|
|
9
|
+
import {SetNewPassword} from "./components/SetNewPassword"
|
|
10
10
|
import { getAuthProps } from "./authProps"
|
|
11
11
|
|
|
12
12
|
const hasInitialized = false
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|