Skip to content

Commit

Permalink
🐛 fix: 401 오류 발생 시 로그인 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
kms0219kms committed Dec 31, 2023
1 parent dd10bdc commit 4b0d9a0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
17 changes: 10 additions & 7 deletions pages/dashboard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</h1>

<transition name="contents">
<div v-if="connState == 1">
<div v-if="connState === 1">
<div class="cards grid grid-cols-4 gap-3">
<div class="card">
<div class="card_content">
Expand Down Expand Up @@ -112,7 +112,7 @@
<div class="card_content alert_content">
<div class="alert_title flex items-center mb-3 text-xl" :class="'title_' + [item.kind]">
<svg
v-if="item.kind == 'alert'"
v-if="item.kind === 'alert'"
clip-rule="evenodd"
fill-rule="evenodd"
stroke-linejoin="round"
Expand All @@ -126,7 +126,7 @@
/>
</svg>
<svg
v-if="item.kind == 'success'"
v-if="item.kind === 'success'"
clip-rule="evenodd"
fill-rule="evenodd"
stroke-linejoin="round"
Expand All @@ -140,7 +140,7 @@
/>
</svg>
<svg
v-if="item.kind == 'warning'"
v-if="item.kind === 'warning'"
clip-rule="evenodd"
fill-rule="evenodd"
stroke-linejoin="round"
Expand All @@ -154,7 +154,7 @@
/>
</svg>
<svg
v-if="item.kind == 'danger'"
v-if="item.kind === 'danger'"
clip-rule="evenodd"
fill-rule="evenodd"
stroke-linejoin="round"
Expand All @@ -168,7 +168,7 @@
/>
</svg>
<svg
v-if="item.kind == 'emerg'"
v-if="item.kind === 'emerg'"
clip-rule="evenodd"
fill-rule="evenodd"
stroke-linejoin="round"
Expand Down Expand Up @@ -508,7 +508,10 @@ export default {
this.connState = 1
} catch (e) {
if (e.response) {
if (e.response.data.message == 'Missing Access') {
if (e.response.status === 401) {
window.localStorage.removeItem('access_token')
this.$router.push(`/${this.$i18n.locale}/auth/login`)
} else if (e.response.data.message === 'Missing Access') {
this.$router.push(`/${this.$i18n.locale}/servers`)
}
}
Expand Down
9 changes: 6 additions & 3 deletions pages/dashboard/invite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ $t('invite.title') }}
</h1>
<transition name="contents">
<div v-if="connState == 1">
<div v-if="connState === 1">
<div class="mb-6">
<h2>
<!-- 보안 초대링크 -->
Expand Down Expand Up @@ -350,7 +350,7 @@ export default {
).data
this.isPermission = settings.koreanbots.data.voted
this.isEnterprise = settings.payData?.type == 'ENTERPRISE' && new Date().getTime() < settings.payData?.expire
this.isEnterprise = settings.payData?.type === 'ENTERPRISE' && new Date().getTime() < settings.payData?.expire
if (settings.settings) {
if (settings.settings.status != 0) {
Expand All @@ -377,7 +377,10 @@ export default {
this.connState = 1
} catch (e) {
if (e.response) {
if (e.response.data.message == 'Missing Access') {
if (e.response.status === 401) {
window.localStorage.removeItem('access_token')
this.$router.push(`/${this.$i18n.locale}/auth/login`)
} else if (e.response.data.message === 'Missing Access') {
this.$router.push(`/${this.$i18n.locale}/servers`)
}
}
Expand Down
7 changes: 5 additions & 2 deletions pages/dashboard/members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ $t('members.title') }}
</h1>
<transition name="contents">
<div v-if="connState == 1">
<div v-if="connState === 1">
<input
:placeholder="$t('members.searchPlaceholder')"
class="mb-4 shrink-0"
Expand Down Expand Up @@ -200,7 +200,10 @@ export default {
this.connState = 1
} catch (e) {
if (e.response) {
if (e.response.data.message == 'Missing Access') {
if (e.response.status === 401) {
window.localStorage.removeItem('access_token')
this.$router.push(`/${this.$i18n.locale}/auth/login`)
} else if (e.response.data.message === 'Missing Access') {
this.$router.push(`/${this.$i18n.locale}/servers`)
}
}
Expand Down
9 changes: 6 additions & 3 deletions pages/dashboard/verify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</h1>

<transition name="contents">
<div v-if="connState == 1">
<div v-if="connState === 1">
<h2>
<!-- 커맨드 인증 설정 -->
{{ $t('verify.category1.title') }}
Expand Down Expand Up @@ -55,7 +55,7 @@
:placeholder="$t('verify.category1.rolePlaceholder')"
/>
<ul class="list-l" v-if="list.role.show">
<li v-for="(role, index) in list.role.list" @click="input.role = role">
<li v-for="(role, index) in list.role.list" @click="input.role = role" v-bind:key="index">
{{ role?.name }}
</li>
</ul>
Expand Down Expand Up @@ -158,7 +158,10 @@ export default {
this.connState = 1
} catch (e) {
if (e.response) {
if (e.response.data.message == 'Missing Access') {
if (e.response.status === 401) {
window.localStorage.removeItem('access_token')
this.$router.push(`/${this.$i18n.locale}/auth/login`)
} else if (e.response.data.message === 'Missing Access') {
this.$router.push(`/${this.$i18n.locale}/servers`)
}
}
Expand Down
8 changes: 6 additions & 2 deletions pages/servers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<SpinerList :type="1" :state="connState" />

<transition name="serverList">
<div v-if="connState == 1" class="servers grid gap-8">
<div v-if="connState === 1" class="servers grid gap-8">
<div
v-for="(server, index) in serverList"
v-bind:key="index"
Expand Down Expand Up @@ -187,14 +187,18 @@ export default {
this.connState = 1
} catch (e) {
console.log(e.response)
if (e.response?.status == 429) {
if (e.response?.status === 429) {
setTimeout(() => {
window.location.reload()
}, e.response?.data.error.retry_after * 1000)
} else if (e.response?.status === 401) {
window.localStorage.removeItem('access_token')
this.$router.push(`/${this.$i18n.locale}/auth/login`)
} else {
this.connState = 2
}
}
return
} else {
this.$router.push(`/${this.$i18n.locale}/auth/login`)
Expand Down

0 comments on commit 4b0d9a0

Please sign in to comment.