Skip to content

Commit cdf0eaf

Browse files
authored
Merge pull request #63 from hypersign-protocol/develop
Develop
2 parents d1d36e0 + 2f588a4 commit cdf0eaf

File tree

14 files changed

+349
-280
lines changed

14 files changed

+349
-280
lines changed

src/App.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ export default {
362362
const userDetails = localStorage.getItem("user");
363363
if (userDetails) {
364364
try {
365-
this.userDetails = JSON.parse(userDetails);
365+
const parsed = JSON.parse(userDetails);
366+
Object.assign(this.userDetails, parsed);
366367
this.user = this.userDetails;
367368
this.loggedInUserEmailId = this.user?.accessAccount?.email;
368369
this.setIsLoggedOut(true);
@@ -483,7 +484,8 @@ export default {
483484
try {
484485
const userDetails = localStorage.getItem("user");
485486
if (userDetails) {
486-
this.userDetails = JSON.parse(userDetails);
487+
const parsed = JSON.parse(userDetails);
488+
Object.assign(this.userDetails, parsed);
487489
this.parseAuthToken= this.userDetails
488490
this.setIsLoggedOut(true)
489491
const redirectPath=localStorage.getItem("postLoginRedirect")||'/studio/dashboard'
@@ -666,7 +668,7 @@ export default {
666668
},
667669
async logout() {
668670
try{
669-
await RequestHandler(`${config.studioServer.BASE_URL}api/v1/logout`, 'POST', {})
671+
await RequestHandler(`${config.studioServer.BASE_URL}api/v1/auth/logout`, 'POST', {})
670672
}catch(e){
671673
console.error('Logout error:', e);
672674
}

src/assets/css/gblStyle.css

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,18 @@ a {
146146
background-color: #fff;
147147
background-clip: border-box;
148148
border: 1px solid rgba(0, 0, 0, .125);
149-
}
150-
149+
max-height: 80vh;
150+
overflow-y: auto;
151+
}
152+
153+
.serviceCard.v-card,
154+
.serviceCard.v-sheet {
155+
border-radius: 8px !important;
156+
box-shadow: 0 0 2rem 0 rgba(136, 152, 170, 0.15) !important;
157+
}
151158
.dropDownPopup {
152159
box-shadow: var(--dropdown-menu-elevation, 0 1px 10px 0 rgba(0, 0, 0, .25));
153160
border-radius: 8px;
154161
border: 0px solid grey;
155162
}
156-
163+

src/router.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,8 @@ router.beforeEach(async (to, from, next) => {
211211
}
212212
if (to.matched.some(record => record.meta.requiresAuth)) {
213213
document.title = to.meta.title;
214-
const url = `${config.studioServer.BASE_URL}api/v1/auth`
215214
try {
216-
217-
const response = await fetch(url, {
215+
const response = await fetch(`${config.studioServer.BASE_URL}api/v1/auth`, {
218216
method: "POST",
219217
credentials: "include",
220218
});
@@ -225,20 +223,34 @@ router.beforeEach(async (to, from, next) => {
225223
localStorage.setItem("user", JSON.stringify(json.message));
226224
store.commit('playgroundStore/addUserDetailsToProfile', json.message)
227225
next()
228-
} else {
229-
throw new Error("Unexpected response");
230226
}
231227
} catch (e) {
232-
console.log(e)
233-
store.commit('mainStore/setMainSideNavBar', false)
234-
next({
235-
path: '/studio/login',
236-
query: { redirect: to.fullPath }
237-
})
238-
228+
try {
229+
const refreshResponse = await fetch(`${config.studioServer.BASE_URL}api/v1/auth/refresh`, {
230+
method: "POST",
231+
credentials: "include",
232+
});
233+
if (!refreshResponse.ok) {
234+
throw new Error('Refresh failed');
235+
}
236+
const authResponse = await fetch(`${config.studioServer.BASE_URL}api/v1/auth`, {
237+
method: "POST",
238+
credentials: "include",
239+
});
240+
if (authResponse.ok) {
241+
const user = await authResponse.json();
242+
localStorage.setItem("user", JSON.stringify(user.message));
243+
store.commit('playgroundStore/addUserDetailsToProfile', user.message);
244+
next();
245+
} else {
246+
throw new Error('Refresh token invalid');
247+
}
248+
} catch (refreshError) {
249+
store.commit('mainStore/setMainSideNavBar', false);
250+
next({ path: '/studio/login', query: { redirect: to.fullPath } });
251+
}
239252
}
240253
} else {
241-
console.log(to.path)
242254
if (to.path === '/studio/login') {
243255
store.commit('mainStore/setIsLoggedOut', false)
244256
}

0 commit comments

Comments
 (0)