@@ -4,7 +4,7 @@ import VueGtag from "vue-gtag";
44
55import App from "./App.vue" ;
66import api from "./api" ;
7- import appStore , { User } from "./appStore" ;
7+ import appStore , { User } from "./appStore" ;
88import * as filters from "./helpers/fiters" ;
99import routes from "./routes" ;
1010import socket from "./socket" ;
@@ -24,21 +24,21 @@ document.querySelector("html").classList.add("dark");
2424
2525const router = new VueRouter ( { routes } ) ;
2626Vue . use ( VueRouter ) ;
27- router . beforeEach ( ( to , from , next ) => {
27+ router . beforeEach ( async ( to , from , next ) => {
2828 if ( to . meta . title ) {
29- document . title = `${ to . meta . title } - Cybertown` ;
29+ document . title = `${ to . meta . title } - Cybertown` ;
3030 } else {
3131 document . title = "Cybertown" ;
3232 }
3333 if ( to . fullPath . includes ( "/place/" ) ) {
34- api . get < any > ( `/place/${ to . params . id } ` )
34+ await api . get < any > ( `/place/${ to . params . id } ` )
3535 . then ( response => {
3636 const Data = response . data ;
37- const place = { ...Data . place } ;
37+ const place = { ...Data . place } ;
3838 appStore . methods . setPlace ( place ) ;
3939 } ) ;
4040 } else if ( to . fullPath . includes ( "/club/" ) ) {
41- api . get < any > ( `/place/by_id/${ to . params . id } ` )
41+ await api . get < any > ( `/place/by_id/${ to . params . id } ` )
4242 . then ( response => {
4343 const Data = response . data ;
4444 //check if user is a member of the club
@@ -56,50 +56,51 @@ router.beforeEach((to, from, next) => {
5656 } ;
5757 appStore . methods . setPlace ( place ) ;
5858 } ) ;
59- } else if ( to . fullPath . includes ( "/inbox/" ) || to . fullPath . includes ( "/messageboard/" ) ) {
60- api . get < any > ( `/place/by_id/${ to . params . place_id } ` )
61- . then ( response => {
62- const Data = response . data ;
63- if ( Data . place . type === 'club' && Data . place . private ) {
64- api . get < any > ( `/club/ismember?clubId=${ Data . place . id } ` )
59+ } else if ( to . fullPath . includes ( "/inbox/" ) || to . fullPath . includes ( "/messageboard/" ) ) {
60+ await api . get < any > ( `/place/by_id/${ to . params . place_id } ` )
61+ . then ( response => {
62+ const Data = response . data ;
63+ if ( Data . place . type === 'club' && Data . place . private ) {
64+ api . get < any > ( `/club/ismember?clubId=${ Data . place . id } ` )
6565 . then ( response => {
6666 const member = response . data . isMember ;
67- if ( ! member && to . fullPath . includes ( "/messageboard/" ) ) {
67+ if ( ! member && to . fullPath . includes ( "/messageboard/" ) ) {
6868 api . post < any > ( `/messageboard/getadmininfo/` , {
6969 place_id : Data . place . id ,
7070 type : Data . place . type
7171 } ) . then ( response => {
72- if ( ! response . data . admin ) {
72+ if ( ! response . data . admin ) {
7373 next ( `/clubdoor/${ Data . place . id } ` )
7474 }
7575 } )
7676 }
77- if ( ! member && to . fullPath . includes ( "/inbox/" ) ) {
77+ if ( ! member && to . fullPath . includes ( "/inbox/" ) ) {
7878 api . post < any > ( `/inbox/getadmininfo/` , {
7979 place_id : Data . place . id ,
8080 type : Data . place . type
8181 } ) . then ( response => {
82- if ( ! response . data . admin ) {
82+ if ( ! response . data . admin ) {
8383 next ( '/clubdoor/${Data.place.id}' )
8484 }
8585 } )
8686 }
8787 } ) ;
88- } } ) ;
88+ }
89+ } ) ;
8990 } else if ( to . fullPath . includes ( "/clubdoor/" ) ) {
90- api . get < any > ( `/place/by_id/${ to . params . id } ` )
91+ await api . get < any > ( `/place/by_id/${ to . params . id } ` )
9192 . then ( response => {
9293 const Data = response . data ;
9394 appStore . methods . setPlace ( Data . place ) ;
9495 } ) ;
95- } else if ( to . fullPath . includes ( "/home/" ) ) {
96- api . get < any > ( `/home/${ to . params . username } ` )
96+ } else if ( to . fullPath . includes ( "/home/" ) ) {
97+ await api . get < any > ( `/home/${ to . params . username } ` )
9798 . then ( response => {
9899 const Data = response . data ;
99100 const place = {
100101 ...Data . homeData ,
101102 assets_dir : Data . homeDesignData ?
102- ( `${ Data . homeDesignData . id } /` ) : null ,
103+ ( `${ Data . homeDesignData . id } /` ) : null ,
103104 world_filename : "home.wrl" ,
104105 slug : "home" ,
105106 block : Data . blockData ,
@@ -111,7 +112,7 @@ router.beforeEach((to, from, next) => {
111112 if ( ! [ "login" , "logout" , "signup" , "forgot" , "password_reset" ,
112113 "about" , "privacypolicy" , "rulesandregulations" , "constitution" , "banned" ]
113114 . includes ( to . name ) ) {
114- api . get < {
115+ await api . get < {
115116 user : User ,
116117 status : number ,
117118 roleName : string ,
@@ -120,14 +121,14 @@ router.beforeEach((to, from, next) => {
120121 } > ( "/member/session" )
121122 . then ( response => {
122123 const { user } = response . data ;
123- const { banInfo, banned } = response . data ;
124+ const { banInfo, banned } = response . data ;
124125 if ( banned ) {
125126 if (
126127 banInfo . type === "jail" &&
127- to . fullPath . includes ( "/messageboard/" ) ||
128- to . fullPath . includes ( "/inbox/" ) ||
129- to . fullPath . includes ( "/information/" )
130- ) {
128+ to . fullPath . includes ( "/messageboard/" ) ||
129+ to . fullPath . includes ( "/inbox/" ) ||
130+ to . fullPath . includes ( "/information/" )
131+ ) {
131132 next ( "/restricted" ) ;
132133 } else if ( to . fullPath === "/restricted" ) {
133134 next ( ) ;
@@ -136,7 +137,7 @@ router.beforeEach((to, from, next) => {
136137 api . get < any > ( "/place/jail" )
137138 . then ( response => {
138139 const Data = response . data ;
139- const place = { ...Data . place } ;
140+ const place = { ...Data . place } ;
140141 appStore . methods . setPlace ( place ) ;
141142 } ) ;
142143 } else if ( to . fullPath === "/place/jail" ) {
0 commit comments