Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 65 | Rev 71 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 65 Rev 66
Línea 1... Línea 1...
1
import { axios } from "../../utils";
1
import { axios } from "../../utils";
2
import { actionsTypes } from "./auth.types";
2
import { actionsTypes } from "./auth.types";
Línea 3... Línea 3...
3
 
3
 
4
const getPermissions = () => {
4
const getPermissions = () => {
5
  return (dispatch) => {
-
 
6
    dispatch(startLoading());
5
  return (dispatch) => {
7
    axios
6
    axios
8
      .get("/signin", { headers: { "Content-Type": "application/json" } })
7
      .get("/signin", { headers: { "Content-Type": "application/json" } })
9
      .then((response) => {
8
      .then((response) => {
Línea 27... Línea 26...
27
  };
26
  };
28
};
27
};
Línea 29... Línea 28...
29
 
28
 
30
export const validateAuth = () => {
29
export const validateAuth = () => {
-
 
30
  return (dispatch) => {
-
 
31
    dispatch(startLoading());
31
  return (dispatch) => {
32
 
Línea 32... Línea 33...
32
    const token = window.localStorage.getItem("jwt");
33
    const token = window.localStorage.getItem("jwt");
33
 
34
 
-
 
35
    if (token) {
34
    if (token) {
36
      dispatch(login());
-
 
37
      dispatch(stopLoading());
35
      dispatch(login());
38
    } else {
36
      return null;
-
 
37
    }
-
 
38
 
39
      dispatch(getPermissions());
39
    dispatch(getPermissions());
40
    }
Línea 40... Línea 41...
40
  };
41
  };
41
};
42
};
Línea 51... Línea 52...
51
 
52
 
52
export const stopLoading = () => ({
53
export const stopLoading = () => ({
53
  type: actionsTypes.STOP_LOADING,
54
  type: actionsTypes.STOP_LOADING,
Línea 54... Línea 55...
54
});
55
});
55
 
-
 
56
export const login = () => {
-
 
57
  console.log("Processing login");
56
 
58
  return {
-
 
59
    type: actionsTypes.LOGIN,
57
export const login = () => ({
Línea 60... Línea 58...
60
  };
58
  type: actionsTypes.LOGIN,
61
};
59
});
62
 
60