@rpcbase/client 0.39.0 → 0.41.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/get_uid.js +11 -0
- package/auth/index.js +5 -16
- package/auth/views.js +14 -0
- package/package.json +1 -1
package/auth/get_uid.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import {Platform} from "react-native"
|
|
3
|
+
|
|
4
|
+
import {get_uid as _get_uid} from "./index"
|
|
5
|
+
|
|
6
|
+
const get_uid = Platform.OS === "web" ? _get_uid : () => {
|
|
7
|
+
console.warn("native should not call get_uid, use userId from AuthContext")
|
|
8
|
+
return null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default get_uid
|
package/auth/index.js
CHANGED
|
@@ -2,28 +2,17 @@
|
|
|
2
2
|
import page from "page"
|
|
3
3
|
import debug from "debug"
|
|
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"
|
|
10
|
-
|
|
11
5
|
import post from "../helpers/post"
|
|
12
6
|
|
|
13
|
-
export {
|
|
14
|
-
SignIn,
|
|
15
|
-
SignUp,
|
|
16
|
-
SignOut,
|
|
17
|
-
ForgotPassword,
|
|
18
|
-
SetNewPassword,
|
|
19
|
-
}
|
|
20
7
|
|
|
21
8
|
const UID_STORAGE_KEY = "rb::session-user_id"
|
|
22
9
|
|
|
23
10
|
const log = debug("rb:auth")
|
|
24
11
|
|
|
12
|
+
// TODO: this should be refactored to AuthContext + Provider
|
|
13
|
+
|
|
25
14
|
let __is_authenticated = null
|
|
26
|
-
let __user_id = localStorage
|
|
15
|
+
let __user_id = localStorage?.getItem(UID_STORAGE_KEY)
|
|
27
16
|
|
|
28
17
|
|
|
29
18
|
const run_session_check = async() => {
|
|
@@ -37,8 +26,8 @@ const run_session_check = async() => {
|
|
|
37
26
|
}
|
|
38
27
|
}
|
|
39
28
|
|
|
40
|
-
// Force trigger run first session check
|
|
41
|
-
run_session_check()
|
|
29
|
+
// Force trigger run first session check (when we are not in a webworker)
|
|
30
|
+
if (typeof window !== "undefined") run_session_check()
|
|
42
31
|
|
|
43
32
|
// manually run first check
|
|
44
33
|
// TODO: this should come from localStorage
|
package/auth/views.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import SignIn from "./SignIn"
|
|
3
|
+
import SignUp from "./SignUp"
|
|
4
|
+
import SignOut from "./SignOut"
|
|
5
|
+
import ForgotPassword from "./ForgotPassword"
|
|
6
|
+
import SetNewPassword from "./SetNewPassword"
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
SignIn,
|
|
10
|
+
SignUp,
|
|
11
|
+
SignOut,
|
|
12
|
+
ForgotPassword,
|
|
13
|
+
SetNewPassword,
|
|
14
|
+
}
|