|
@@ -41,11 +41,11 @@ export function LoginCs() {
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
const handleClose = () => false
|
|
const handleClose = () => false
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
|
- let auth = useSelector((state) => state.token.candi)
|
|
|
|
|
|
|
+ const auth = useSelector((state) => state.token.candi)
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
React.useEffect(() => {
|
|
|
if(auth){
|
|
if(auth){
|
|
|
- let body_token = jwt_decode(auth.token);
|
|
|
|
|
|
|
+ const body_token = jwt_decode(auth.token);
|
|
|
if(body_token.authorities.includes("Candidato")){
|
|
if(body_token.authorities.includes("Candidato")){
|
|
|
navigate('/user/home')
|
|
navigate('/user/home')
|
|
|
}
|
|
}
|
|
@@ -59,13 +59,13 @@ export function LoginCs() {
|
|
|
password: '',
|
|
password: '',
|
|
|
},
|
|
},
|
|
|
validationSchema: LoginSchema,
|
|
validationSchema: LoginSchema,
|
|
|
- onSubmit: async (values) => {
|
|
|
|
|
|
|
+ onSubmit: (values) => {
|
|
|
|
|
|
|
|
- let { email, password } = values
|
|
|
|
|
|
|
+ const { email, password } = values
|
|
|
setOpen(true)
|
|
setOpen(true)
|
|
|
|
|
|
|
|
- let url = `/user?user=${email}&password=${password}&typeusr=iscandidato`
|
|
|
|
|
- let request = new Service(url);
|
|
|
|
|
|
|
+ const url = `/user?user=${email}&password=${password}&typeusr=iscandidato`
|
|
|
|
|
+ const request = new Service(url);
|
|
|
request
|
|
request
|
|
|
.post({})
|
|
.post({})
|
|
|
.then(response => {
|
|
.then(response => {
|
|
@@ -74,13 +74,13 @@ export function LoginCs() {
|
|
|
let { token, nombre, apelidos, idcontrasenia : pass_id, idSueperContrasenia } = response;
|
|
let { token, nombre, apelidos, idcontrasenia : pass_id, idSueperContrasenia } = response;
|
|
|
toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
|
|
toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
|
|
|
token = token.replace("Bearer ", "")
|
|
token = token.replace("Bearer ", "")
|
|
|
- let { exp } = jwt_decode(token);
|
|
|
|
|
- let body_token = jwt_decode(token);
|
|
|
|
|
|
|
+ const { exp } = jwt_decode(token);
|
|
|
|
|
+ const body_token = jwt_decode(token);
|
|
|
console.log('body_toke: ', body_token)
|
|
console.log('body_toke: ', body_token)
|
|
|
body_token['pass'] = password;
|
|
body_token['pass'] = password;
|
|
|
body_token['passid'] = pass_id;
|
|
body_token['passid'] = pass_id;
|
|
|
|
|
|
|
|
- let timestamp = exp * 1000;
|
|
|
|
|
|
|
+ const timestamp = exp * 1000;
|
|
|
let exp_in = timestamp - Date.now();
|
|
let exp_in = timestamp - Date.now();
|
|
|
let profile = {
|
|
let profile = {
|
|
|
email,
|
|
email,
|