@rpcbase/client 0.28.0 → 0.30.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.
@@ -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/index.js CHANGED
@@ -20,8 +20,6 @@ export {
20
20
 
21
21
  const UID_STORAGE_KEY = "rb::session-user_id"
22
22
 
23
- console.log("wow client")
24
-
25
23
  const log = debug("rb:auth")
26
24
 
27
25
  let __is_authenticated = null
@@ -30,12 +28,11 @@ let __user_id = localStorage.getItem(UID_STORAGE_KEY)
30
28
 
31
29
  const run_session_check = async() => {
32
30
  const res = await post("/api/v1/auth/check_session")
33
- const {is_signed_in, user_id} = res
34
- log("check_session response", res)
35
- __is_authenticated = is_signed_in
36
- __user_id = user_id
31
+ console.log("check_session response", res)
32
+ __user_id = res.user_id
33
+ __is_authenticated = res.is_signed_in
37
34
  // cache user_id in localStorage
38
- if (user_id) {
35
+ if (__user_id) {
39
36
  localStorage.setItem(UID_STORAGE_KEY, user_id)
40
37
  }
41
38
  }
@@ -81,6 +78,7 @@ export const session_restrict = (ctx, next) => {
81
78
 
82
79
 
83
80
  export const get_uid = () => __user_id
81
+ export const set_uid = (val) => __user_id = val
84
82
 
85
83
  export const set_is_signed_in = (val) => __is_authenticated = val
86
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 0"
6
6
  },