@rpcbase/client 0.29.0 → 0.31.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/SignIn/index.js +2 -1
- package/auth/SignOut/index.js +2 -1
- package/auth/index.js +6 -6
- package/package.json +1 -1
package/auth/SignIn/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import debug from "debug"
|
|
|
7
7
|
|
|
8
8
|
import post from "../../helpers/post"
|
|
9
9
|
|
|
10
|
-
import {set_is_signed_in} from "../index"
|
|
10
|
+
import {set_is_signed_in, set_uid} from "../index"
|
|
11
11
|
import Footer from "../Footer"
|
|
12
12
|
|
|
13
13
|
import "./sign-in.scss"
|
|
@@ -50,6 +50,7 @@ const SignIn = ({
|
|
|
50
50
|
if (res.status === "ok") {
|
|
51
51
|
log("signed in res: ok", res)
|
|
52
52
|
log("redirect to:", redirect || onSuccessRedirect)
|
|
53
|
+
set_uid(res.user_id)
|
|
53
54
|
set_is_signed_in(true)
|
|
54
55
|
if (redirect) {
|
|
55
56
|
page(redirect)
|
package/auth/SignOut/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {ActivityIndicator} from "react-native"
|
|
|
4
4
|
import page from "page"
|
|
5
5
|
|
|
6
6
|
import post from "../../helpers/post"
|
|
7
|
-
import {set_is_signed_in} from "../index"
|
|
7
|
+
import {set_is_signed_in, set_uid} from "../index"
|
|
8
8
|
|
|
9
9
|
const SignOut = () => {
|
|
10
10
|
|
|
@@ -14,6 +14,7 @@ const SignOut = () => {
|
|
|
14
14
|
setTimeout(async() => {
|
|
15
15
|
const res = await post("/api/v1/auth/sign_out")
|
|
16
16
|
if (res.status === "ok") {
|
|
17
|
+
set_uid(null)
|
|
17
18
|
set_is_signed_in(false)
|
|
18
19
|
localStorage.clear()
|
|
19
20
|
setIsSignedOut(true)
|
package/auth/index.js
CHANGED
|
@@ -28,13 +28,12 @@ let __user_id = localStorage.getItem(UID_STORAGE_KEY)
|
|
|
28
28
|
|
|
29
29
|
const run_session_check = async() => {
|
|
30
30
|
const res = await post("/api/v1/auth/check_session")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
__is_authenticated = is_signed_in
|
|
34
|
-
__user_id = user_id
|
|
31
|
+
console.log("check_session response", res)
|
|
32
|
+
__user_id = res.user_id
|
|
33
|
+
__is_authenticated = res.is_signed_in
|
|
35
34
|
// cache user_id in localStorage
|
|
36
|
-
if (
|
|
37
|
-
localStorage.setItem(UID_STORAGE_KEY,
|
|
35
|
+
if (__user_id) {
|
|
36
|
+
localStorage.setItem(UID_STORAGE_KEY, __user_id)
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -79,6 +78,7 @@ export const session_restrict = (ctx, next) => {
|
|
|
79
78
|
|
|
80
79
|
|
|
81
80
|
export const get_uid = () => __user_id
|
|
81
|
+
export const set_uid = (val) => __user_id = val
|
|
82
82
|
|
|
83
83
|
export const set_is_signed_in = (val) => __is_authenticated = val
|
|
84
84
|
|