Commit 8deade1932c671bb48fc3cfe1750135df5040267
1 parent
de2bd4eb9e
Exists in
master
and in
3 other branches
token issue solved
Showing
5 changed files
with
67 additions
and
58 deletions
Show diff stats
src/Services/http.js
... | ... | @@ -4,18 +4,21 @@ import store from '@/store/store' |
4 | 4 | const baseDomain = "http://15.206.52.174:8001/v1"; |
5 | 5 | |
6 | 6 | const baseURL = `${baseDomain}`; |
7 | -var token = "" | |
8 | -if (store.state.role === "ADMIN") { | |
9 | - token = `${store.state.token}` | |
10 | -} else if (store.state.schoolRole === "SUPERADMIN") { | |
11 | - token = `${store.state.schoolToken}` | |
12 | -} | |
7 | +// var token = "" | |
8 | +// if (store.state.role === "ADMIN") { | |
9 | +// token = `${store.state.token}` | |
10 | +// } else if (store.state.schoolRole === "SUPERADMIN") { | |
11 | +// token = `${store.state.schoolToken}` | |
12 | +// } | |
13 | + | |
14 | +// console.log("role",`${store.state.schoolRole}`); | |
15 | +// console.log("token",`${store.state.schoolToken}`); | |
13 | 16 | export default () => { |
14 | 17 | return axios.create({ |
15 | 18 | // baseURL: 'http://192.168.0.127:3002/v1', |
16 | 19 | baseURL, |
17 | 20 | headers: { |
18 | - Authorization: `Bearer ${token}` | |
21 | + Authorization: `Bearer ${store.state.token}` | |
19 | 22 | } |
20 | 23 | }) |
21 | 24 | } |
22 | 25 | \ No newline at end of file | ... | ... |
src/components/pageHeader/AppToolbar.vue
src/pages/Authentication/Login.vue
... | ... | @@ -156,9 +156,9 @@ export default { |
156 | 156 | if (this.$store.state.isUserLoggedIn == true) { |
157 | 157 | this.$router.push("/dashboard"); |
158 | 158 | } |
159 | - // else if (this.$store.state.isSchoolLoggedIn == true) { | |
160 | - // this.$router.push("/school"); | |
161 | - // } | |
159 | + else if (this.$store.state.isSchoolLoggedIn == true) { | |
160 | + this.$router.push("/dashboard"); | |
161 | + } | |
162 | 162 | }, |
163 | 163 | computed: { |
164 | 164 | color() { | ... | ... |
src/pages/Dashboard/dashboard.vue
... | ... | @@ -418,8 +418,14 @@ export default { |
418 | 418 | }; |
419 | 419 | }, |
420 | 420 | mounted() { |
421 | - this.token = this.$store.state.token; | |
422 | - // console.log("this.$store.state.role", this.$store.state.schoolRole); | |
421 | + // = this.$store.state.schoolToken; | |
422 | + // console.log("this.$store.state.role", this.token); | |
423 | + if (this.$store.state.role === "ADMIN") { | |
424 | + this.token = this.$store.state.token; | |
425 | + } else if (this.$store.state.schoolRole === "SUPERADMIN") { | |
426 | + this.token = this.$store.state.schoolToken; | |
427 | + } | |
428 | + // console.log("role", this.$store.state.schoolRole,"tt",this.$store.state.schoolToken); | |
423 | 429 | // this.getData(); |
424 | 430 | this.getStudents(); |
425 | 431 | this.getTeachers(); |
... | ... | @@ -462,9 +468,9 @@ export default { |
462 | 468 | getStudents() { |
463 | 469 | http() |
464 | 470 | .get("/getStudentsList", { |
465 | - // headers: { | |
466 | - // Authorization: "Bearer " + this.$store.state.token | |
467 | - // } | |
471 | + headers: { | |
472 | + Authorization: "Bearer " + this.token | |
473 | + } | |
468 | 474 | }) |
469 | 475 | .then(response => { |
470 | 476 | this.students = response.data.data; |
... | ... | @@ -473,19 +479,19 @@ export default { |
473 | 479 | .catch(error => { |
474 | 480 | // console.log("err====>", err); |
475 | 481 | this.showLoader = false; |
476 | - if (error.response.status === 401) { | |
477 | - this.$router.replace({ path: "/" }); | |
478 | - this.$store.dispatch("setToken", null); | |
479 | - this.$store.dispatch("Id", null); | |
480 | - } | |
482 | + // if (error.response.status === 401) { | |
483 | + // this.$router.replace({ path: "/" }); | |
484 | + // this.$store.dispatch("setToken", null); | |
485 | + // this.$store.dispatch("Id", null); | |
486 | + // } | |
481 | 487 | }); |
482 | 488 | }, |
483 | 489 | getParents() { |
484 | 490 | http() |
485 | 491 | .get("/getParentsList", { |
486 | - // headers: { | |
487 | - // Authorization: "Bearer " + this.$store.state.token | |
488 | - // } | |
492 | + headers: { | |
493 | + Authorization: "Bearer " + this.token | |
494 | + } | |
489 | 495 | }) |
490 | 496 | .then(response => { |
491 | 497 | this.parents = response.data.data; |
... | ... | @@ -494,19 +500,19 @@ export default { |
494 | 500 | .catch(error => { |
495 | 501 | // console.log("err====>", err); |
496 | 502 | this.showLoader = false; |
497 | - if (error.response.status === 401) { | |
498 | - this.$router.replace({ path: "/" }); | |
499 | - this.$store.dispatch("setToken", null); | |
500 | - this.$store.dispatch("Id", null); | |
501 | - } | |
503 | + // if (error.response.status === 401) { | |
504 | + // this.$router.replace({ path: "/" }); | |
505 | + // this.$store.dispatch("setToken", null); | |
506 | + // this.$store.dispatch("Id", null); | |
507 | + // } | |
502 | 508 | }); |
503 | 509 | }, |
504 | 510 | getTeachers() { |
505 | 511 | http() |
506 | 512 | .get("/getTeachersList", { |
507 | - // headers: { | |
508 | - // Authorization: "Bearer " + this.$store.state.token | |
509 | - // } | |
513 | + headers: { | |
514 | + Authorization: "Bearer " + this.token | |
515 | + } | |
510 | 516 | }) |
511 | 517 | .then(response => { |
512 | 518 | this.teachers = response.data.data; |
... | ... | @@ -515,19 +521,19 @@ export default { |
515 | 521 | .catch(error => { |
516 | 522 | // console.log("err====>", err); |
517 | 523 | this.showLoader = false; |
518 | - if (error.response.status === 401) { | |
519 | - this.$router.replace({ path: "/" }); | |
520 | - this.$store.dispatch("setToken", null); | |
521 | - this.$store.dispatch("Id", null); | |
522 | - } | |
524 | + // if (error.response.status === 401) { | |
525 | + // this.$router.replace({ path: "/" }); | |
526 | + // this.$store.dispatch("setToken", null); | |
527 | + // this.$store.dispatch("Id", null); | |
528 | + // } | |
523 | 529 | }); |
524 | 530 | }, |
525 | 531 | getClasses() { |
526 | 532 | http() |
527 | 533 | .get("/getClassesList", { |
528 | - // headers: { | |
529 | - // Authorization: "Bearer " + this.$store.state.token | |
530 | - // } | |
534 | + headers: { | |
535 | + Authorization: "Bearer " + this.token | |
536 | + } | |
531 | 537 | }) |
532 | 538 | .then(response => { |
533 | 539 | this.classes = response.data.data; |
... | ... | @@ -535,21 +541,21 @@ export default { |
535 | 541 | }) |
536 | 542 | .catch(error => { |
537 | 543 | this.showLoader = false; |
538 | - if (error.response.status === 401) { | |
539 | - this.$router.replace({ path: "/" }); | |
540 | - this.$store.dispatch("setToken", null); | |
541 | - this.$store.dispatch("Id", null); | |
542 | - this.$store.dispatch("Role", null); | |
543 | - } | |
544 | + // if (error.response.status === 401) { | |
545 | + // this.$router.replace({ path: "/" }); | |
546 | + // this.$store.dispatch("setToken", null); | |
547 | + // this.$store.dispatch("Id", null); | |
548 | + // this.$store.dispatch("Role", null); | |
549 | + // } | |
544 | 550 | }); |
545 | 551 | }, |
546 | 552 | getNoticeData() { |
547 | 553 | this.showLoader = true; |
548 | 554 | http() |
549 | 555 | .get("/getEventsList", { |
550 | - // headers: { | |
551 | - // Authorization: "Bearer " + this.$store.state.token | |
552 | - // } | |
556 | + headers: { | |
557 | + Authorization: "Bearer " + this.token | |
558 | + } | |
553 | 559 | }) |
554 | 560 | .then(response => { |
555 | 561 | this.noticeData = response.data.data; |
... | ... | @@ -557,20 +563,20 @@ export default { |
557 | 563 | }) |
558 | 564 | .catch(error => { |
559 | 565 | this.showLoader = false; |
560 | - if (error.response.status === 401) { | |
561 | - this.$router.replace({ path: "/" }); | |
562 | - this.$store.dispatch("setToken", null); | |
563 | - this.$store.dispatch("Id", null); | |
564 | - } | |
566 | + // if (error.response.status === 401) { | |
567 | + // this.$router.replace({ path: "/" }); | |
568 | + // this.$store.dispatch("setToken", null); | |
569 | + // this.$store.dispatch("Id", null); | |
570 | + // } | |
565 | 571 | }); |
566 | 572 | }, |
567 | 573 | getUserData() { |
568 | 574 | // this.showLoader = true; |
569 | 575 | http() |
570 | 576 | .get("/getParticularUserDetail", { |
571 | - // headers: { | |
572 | - // Authorization: "Bearer " + this.$store.state.token | |
573 | - // } | |
577 | + headers: { | |
578 | + Authorization: "Bearer " + this.token | |
579 | + } | |
574 | 580 | }) |
575 | 581 | .then(response => { |
576 | 582 | this.userData = response.data.data; | ... | ... |
src/pages/School/school.vue
... | ... | @@ -834,7 +834,7 @@ export default { |
834 | 834 | this.showLoader = true; |
835 | 835 | http() |
836 | 836 | .get("/getSchoolList", { |
837 | - // headers: { Authorization: "Bearer " + this.$store.state.token } | |
837 | + headers: { Authorization: "Bearer " + this.$store.state.schoolToken } | |
838 | 838 | }) |
839 | 839 | .then(response => { |
840 | 840 | this.schoolList = response.data.data; | ... | ... |