diff --git a/src/Services/http.js b/src/Services/http.js index d383d1f..f3f8336 100644 --- a/src/Services/http.js +++ b/src/Services/http.js @@ -4,18 +4,21 @@ import store from '@/store/store' const baseDomain = "http://15.206.52.174:8001/v1"; const baseURL = `${baseDomain}`; -var token = "" -if (store.state.role === "ADMIN") { - token = `${store.state.token}` -} else if (store.state.schoolRole === "SUPERADMIN") { - token = `${store.state.schoolToken}` -} +// var token = "" +// if (store.state.role === "ADMIN") { +// token = `${store.state.token}` +// } else if (store.state.schoolRole === "SUPERADMIN") { +// token = `${store.state.schoolToken}` +// } + +// console.log("role",`${store.state.schoolRole}`); +// console.log("token",`${store.state.schoolToken}`); export default () => { return axios.create({ // baseURL: 'http://192.168.0.127:3002/v1', baseURL, headers: { - Authorization: `Bearer ${token}` + Authorization: `Bearer ${store.state.token}` } }) } \ No newline at end of file diff --git a/src/components/pageHeader/AppToolbar.vue b/src/components/pageHeader/AppToolbar.vue index f8213a8..eee4c96 100644 --- a/src/components/pageHeader/AppToolbar.vue +++ b/src/components/pageHeader/AppToolbar.vue @@ -92,7 +92,7 @@ export default { } }, mounted() { - this.getUserData(); + // this.getUserData(); }, methods: { // emitSearch(ev) { diff --git a/src/pages/Authentication/Login.vue b/src/pages/Authentication/Login.vue index 5b07e43..d8db6e9 100644 --- a/src/pages/Authentication/Login.vue +++ b/src/pages/Authentication/Login.vue @@ -156,9 +156,9 @@ export default { if (this.$store.state.isUserLoggedIn == true) { this.$router.push("/dashboard"); } - // else if (this.$store.state.isSchoolLoggedIn == true) { - // this.$router.push("/school"); - // } + else if (this.$store.state.isSchoolLoggedIn == true) { + this.$router.push("/dashboard"); + } }, computed: { color() { diff --git a/src/pages/Dashboard/dashboard.vue b/src/pages/Dashboard/dashboard.vue index 1eadc5c..7405dbf 100644 --- a/src/pages/Dashboard/dashboard.vue +++ b/src/pages/Dashboard/dashboard.vue @@ -418,8 +418,14 @@ export default { }; }, mounted() { - this.token = this.$store.state.token; - // console.log("this.$store.state.role", this.$store.state.schoolRole); + // = this.$store.state.schoolToken; + // console.log("this.$store.state.role", this.token); + if (this.$store.state.role === "ADMIN") { + this.token = this.$store.state.token; + } else if (this.$store.state.schoolRole === "SUPERADMIN") { + this.token = this.$store.state.schoolToken; + } + // console.log("role", this.$store.state.schoolRole,"tt",this.$store.state.schoolToken); // this.getData(); this.getStudents(); this.getTeachers(); @@ -462,9 +468,9 @@ export default { getStudents() { http() .get("/getStudentsList", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.students = response.data.data; @@ -473,19 +479,19 @@ export default { .catch(error => { // console.log("err====>", err); this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // } }); }, getParents() { http() .get("/getParentsList", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.parents = response.data.data; @@ -494,19 +500,19 @@ export default { .catch(error => { // console.log("err====>", err); this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // } }); }, getTeachers() { http() .get("/getTeachersList", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.teachers = response.data.data; @@ -515,19 +521,19 @@ export default { .catch(error => { // console.log("err====>", err); this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // } }); }, getClasses() { http() .get("/getClassesList", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.classes = response.data.data; @@ -535,21 +541,21 @@ export default { }) .catch(error => { this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - this.$store.dispatch("Role", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // this.$store.dispatch("Role", null); + // } }); }, getNoticeData() { this.showLoader = true; http() .get("/getEventsList", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.noticeData = response.data.data; @@ -557,20 +563,20 @@ export default { }) .catch(error => { this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // } }); }, getUserData() { // this.showLoader = true; http() .get("/getParticularUserDetail", { - // headers: { - // Authorization: "Bearer " + this.$store.state.token - // } + headers: { + Authorization: "Bearer " + this.token + } }) .then(response => { this.userData = response.data.data; diff --git a/src/pages/School/school.vue b/src/pages/School/school.vue index 349a315..e4162a8 100644 --- a/src/pages/School/school.vue +++ b/src/pages/School/school.vue @@ -834,7 +834,7 @@ export default { this.showLoader = true; http() .get("/getSchoolList", { - // headers: { Authorization: "Bearer " + this.$store.state.token } + headers: { Authorization: "Bearer " + this.$store.state.schoolToken } }) .then(response => { this.schoolList = response.data.data;