tokensErrores

This commit is contained in:
Andres2908
2021-01-05 18:54:43 -06:00
parent 015664574b
commit 5b704de6ca
5 changed files with 181 additions and 79 deletions
+34 -9
View File
@@ -142,7 +142,7 @@ export default {
idUsuario: "",
data: [],
total: "",
loading: true,
isLoading: false,
page: 1,
perPage: 25,
numeroCuenta: "",
@@ -224,15 +224,13 @@ export default {
}
currentTotal = this.perPage * contador;
this.total = currentTotal;
this.loading = false;
})
.catch((err) => {
if (error.response.status == 401) {
localStorage.clear();
this.$router.push("/");
}
console.log(err.response.data.message);
this.loading = false;
.catch((error) => {
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
});
},
servicios(idServicio) {
@@ -242,6 +240,33 @@ export default {
getIdLocal() {
this.idUsuario = localStorage.getItem("idUsuario");
},
error(msj) {
if (msj == "jwt expired") {
msj = "Su sesión expiro";
} else if (msj == "invalid signature") {
msj = "El token no es valido";
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (
msj == "El token no es valido" ||
msj == "Su sesión expiro" ||
msj == "No hay token"
) {
localStorage.clear();
this.$router.push("/");
}
},
},
created() {
this.getIdLocal();
+39 -25
View File
@@ -49,6 +49,8 @@
>Enviar</b-button
>
</b-field>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -62,6 +64,7 @@ export default {
file: [],
idServicio: "",
cartaAceptacion: "",
isLoading: false,
token: {
headers: {
token: window.localStorage.getItem("token"),
@@ -92,17 +95,15 @@ export default {
const formData = new FormData();
formData.append("data", JSON.stringify(data));
formData.append("cartaAceptacion", this.file);
console.log(formData);
this.isLoading = true;
axios
.put(
`${process.env.api}/servicio/carta_aceptacion`,
formData,
this.token
)
.put(`${process.env.api}/servicio/carta_aceptacion`, formData, {
headers: {
"Content-Type": "multipart/form-data",
token: this.token.headers.token,
},
})
.then((res) => {
console.log(res.data);
loadingComponent.close();
this.$buefy.dialog.alert({
title: "Success",
message: "Se enviaron los datos correctamente",
@@ -115,24 +116,10 @@ export default {
});
})
.catch((error) => {
loadingComponent.close();
if (error.response.status == 401) {
localStorage.clear();
this.$router.push("/");
}
this.$buefy.dialog.alert({
title: "Error",
message: error.response.data.message,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cartaAceptacion");
@@ -146,6 +133,33 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
if (msj == "jwt expired") {
msj = "Su sesión expiro";
} else if (msj == "invalid signature") {
msj = "El token no es valido";
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (
msj == "El token no es valido" ||
msj == "Su sesión expiro" ||
msj == "No hay token"
) {
localStorage.clear();
this.$router.push("/");
}
},
},
watch: {
file: function(newFile, oldFile) {
+39 -18
View File
@@ -49,6 +49,8 @@
Enviar
</b-button>
</b-field>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -62,6 +64,7 @@ export default {
file: [],
idServicio: "",
cartaTermino: "",
isLoading: false,
token: {
headers: {
token: window.localStorage.getItem("token"),
@@ -93,9 +96,14 @@ export default {
const formData = new FormData();
formData.append("data", JSON.stringify(data));
formData.append("cartaTermino", this.file);
console.log(formData);
this.isLoading = true;
axios
.put(`${process.env.api}/servicio/carta_termino`, formData, this.token)
.put(`${process.env.api}/servicio/carta_termino`, formData, {
headers: {
"Content-Type": "multipart/form-data",
token: this.token.headers.token,
},
})
.then((res) => {
console.log(res.data);
@@ -112,24 +120,10 @@ export default {
});
})
.catch((error) => {
loadingComponent.close();
if (error.response.status == 401) {
localStorage.clear();
this.$router.push("/");
}
this.$buefy.dialog.alert({
title: "Error",
message: error.response.data.message,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cartaTermino");
@@ -143,6 +137,33 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
if (msj == "jwt expired") {
msj = "Su sesión expiro";
} else if (msj == "invalid signature") {
msj = "El token no es valido";
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (
msj == "El token no es valido" ||
msj == "Su sesión expiro" ||
msj == "No hay token"
) {
localStorage.clear();
this.$router.push("/");
}
},
},
watch: {
file: function(newFile, oldFile) {
+34 -17
View File
@@ -160,6 +160,9 @@
>
</b-field>
</section>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -170,6 +173,7 @@ export default {
return {
idServicio: "",
cuestionario: "",
isLoading: false,
actividad1: "",
actividad2: "",
@@ -198,8 +202,8 @@ export default {
p6: this.p6,
p7: this.p7,
};
console.log(data);
this.isLoading = true;
axios
.post(`${process.env.api}/cuestionario_programa`, data, this.token)
.then((res) => {
@@ -216,25 +220,11 @@ export default {
})
.catch((error) => {
loadingComponent.close();
if (error.response.status == 401) {
localStorage.clear();
this.$router.push("/");
}
this.$buefy.dialog.alert({
title: "Error",
message: error.response.data.message,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cuestionario");
@@ -248,6 +238,33 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
if (msj == "jwt expired") {
msj = "Su sesión expiro";
} else if (msj == "invalid signature") {
msj = "El token no es valido";
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (
msj == "El token no es valido" ||
msj == "Su sesión expiro" ||
msj == "No hay token"
) {
localStorage.clear();
this.$router.push("/");
}
},
},
created() {
this.getIdLocal();
+35 -10
View File
@@ -234,7 +234,7 @@ export default {
idUsuario: "",
data: [],
total: "",
loading: true,
isLoading: false,
page: 1,
perPage: 25,
numeroCuenta: "",
@@ -309,7 +309,7 @@ export default {
return `${fecha.year()}/${fecha.month() + 1}/${fecha.date()}`;
},
obtenerDatos(idStatus) {
this.loading = true;
this.isLoading = true;
this.data = [];
axios
.get(
@@ -343,15 +343,13 @@ export default {
}
currentTotal = this.perPage * contador;
this.total = currentTotal;
this.loading = false;
})
.catch((err) => {
if (error.response.status == 401) {
localStorage.clear();
this.$router.push("/");
}
console.log(err.response.data.message);
this.loading = false;
.catch((error) => {
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
});
},
cartaAceptacion(idServicio, idStatus) {
@@ -363,6 +361,33 @@ export default {
this.idTipoUsuario = localStorage.getItem("idTipoUsuario");
this.idUsuario = localStorage.getItem("idUsuario");
},
error(msj) {
if (msj == "jwt expired") {
msj = "Su sesión expiro";
} else if (msj == "invalid signature") {
msj = "El token no es valido";
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (
msj == "El token no es valido" ||
msj == "Su sesión expiro" ||
msj == "No hay token"
) {
localStorage.clear();
this.$router.push("/");
}
},
},
created() {
this.getIdLocal();