@rpcbase/client 0.30.0 → 0.32.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.
@@ -21,7 +21,8 @@ const SIGNIN_WITH_GITHUB = false
21
21
  const SignIn = ({
22
22
  name,
23
23
  logo,
24
- onSuccessRedirect = "/dashboard"
24
+ onSuccessRedirect = "/dashboard",
25
+ onSuccess = () => null
25
26
  }) => {
26
27
  const [isLoading, setIsLoading] = useState(false)
27
28
  const [errors, setErrors] = useState()
@@ -52,6 +53,7 @@ const SignIn = ({
52
53
  log("redirect to:", redirect || onSuccessRedirect)
53
54
  set_uid(res.user_id)
54
55
  set_is_signed_in(true)
56
+ onSuccess()
55
57
  if (redirect) {
56
58
  page(redirect)
57
59
  } else {
@@ -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)
@@ -12,6 +12,7 @@ const SignUp = ({
12
12
  logo,
13
13
  name,
14
14
  onSuccessRedirect = "/dashboard",
15
+ onSuccess = () => null,
15
16
  }) => {
16
17
  const [email, setEmail] = useState("")
17
18
  const [password, setPassword] = useState("")
@@ -26,7 +27,9 @@ const SignUp = ({
26
27
  }
27
28
  const res = await post("/api/v1/auth/sign_up", {email, password})
28
29
  if (res.status === "ok") {
30
+ set_uid(res.user_id)
29
31
  set_is_signed_in(true)
32
+ onSuccess()
30
33
  page(onSuccessRedirect)
31
34
  } else if (res.status === "error") {
32
35
  setError(res.message)
package/auth/index.js CHANGED
@@ -33,7 +33,7 @@ const run_session_check = async() => {
33
33
  __is_authenticated = res.is_signed_in
34
34
  // cache user_id in localStorage
35
35
  if (__user_id) {
36
- localStorage.setItem(UID_STORAGE_KEY, user_id)
36
+ localStorage.setItem(UID_STORAGE_KEY, __user_id)
37
37
  }
38
38
  }
39
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 0"
6
6
  },