Skip to content

Commit 7ba6728

Browse files
committed
Fix routing
1 parent 9ec6fb7 commit 7ba6728

File tree

19 files changed

+156
-146
lines changed

19 files changed

+156
-146
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
repos:
2-
- repo: https://github.com/tekwizely/pre-commit-golang
3-
rev: v1.0.0-rc.1
4-
hooks:
5-
- id: go-fumpt
6-
- id: go-mod-tidy
7-
- id: go-lint
8-
- id: go-imports
9-
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.4.0
11-
hooks:
12-
- id: check-yaml
13-
- id: end-of-file-fixer
14-
- id: trailing-whitespace
15-
16-
- repo: https://github.com/pre-commit/mirrors-prettier
17-
rev: v3.0.0-alpha.4
18-
hooks:
19-
- id: prettier
1+
repos:
2+
- repo: https://github.com/tekwizely/pre-commit-golang
3+
rev: v1.0.0-rc.1
4+
hooks:
5+
- id: go-fumpt
6+
- id: go-mod-tidy
7+
- id: go-lint
8+
- id: go-imports
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.4.0
11+
hooks:
12+
- id: check-yaml
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace
15+
16+
- repo: https://github.com/pre-commit/mirrors-prettier
17+
rev: v3.0.0-alpha.6
18+
hooks:
19+
- id: prettier

web/components/FirebaseAuth.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import { Vue, Component, Prop } from 'vue-property-decorator'
1717
import { ProviderId } from 'firebase/auth'
1818
import { auth } from 'firebaseui'
19+
import firebase from 'firebase/compat'
1920
import { NotificationRequest } from '~/store'
2021
2122
@Component
@@ -44,11 +45,18 @@ export default class FirebaseAuth extends Vue {
4445
uiConfig(): any {
4546
return {
4647
callbacks: {
47-
signInSuccessWithAuthResult: () => {
48+
signInSuccessWithAuthResult: (
49+
authResult: firebase.auth.UserCredential,
50+
) => {
4851
this.$store.dispatch('addNotification', {
4952
message: 'Login successfull!',
5053
type: 'success',
5154
} as NotificationRequest)
55+
56+
this.$store.dispatch('onAuthStateChanged', {
57+
authUser: authResult.user,
58+
})
59+
5260
this.$router.push({ path: this.to })
5361
return false
5462
},
@@ -58,7 +66,7 @@ export default class FirebaseAuth extends Vue {
5866
this.firebaseUIInitialized = true
5967
const container = this.$refs.authContainer as HTMLElement
6068
Array.from(
61-
container.getElementsByClassName('firebaseui-idp-text-long')
69+
container.getElementsByClassName('firebaseui-idp-text-long'),
6270
).forEach((item: Element) => {
6371
item.textContent =
6472
item.textContent?.replace('Sign in with', 'Continue with') || null
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<v-main>
3+
<v-container fluid fill-height>
4+
<v-row align="center" justify="center">
5+
<v-col
6+
cols="12"
7+
md="5"
8+
xl="3"
9+
class="text-center mt-16"
10+
:class="{
11+
'px-6': $vuetify.breakpoint.mdAndDown,
12+
'px-16': !$vuetify.breakpoint.mdAndDown,
13+
}"
14+
>
15+
<h2 class="text-h4 text--secondary mt-16 mb-4">
16+
<img
17+
class="mx-auto d-inline-block"
18+
:src="require('@/assets/img/logo.svg')"
19+
style="max-width: 32px"
20+
alt="httpSMS Logo"
21+
/>
22+
Loading the httpSMS dashboard
23+
</h2>
24+
<v-progress-circular
25+
indeterminate
26+
size="160"
27+
class="mt-8"
28+
color="primary"
29+
></v-progress-circular>
30+
</v-col>
31+
</v-row>
32+
</v-container>
33+
</v-main>
34+
</template>
35+
36+
<script>
37+
export default {
38+
name: 'LoadingDashboard',
39+
}
40+
</script>

web/layouts/default.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
</template>
2020
</v-navigation-drawer>
2121
<v-main :class="{ 'has-drawer': hasDrawer && $vuetify.breakpoint.lgAndUp }">
22-
<Nuxt />
2322
<toast></toast>
23+
<Nuxt v-if="$store.getters.authStateChanged" />
24+
<loading-dashboard v-else></loading-dashboard>
2425
</v-main>
2526
</v-app>
2627
</template>
@@ -39,11 +40,14 @@ export default class DefaultLayout extends Vue {
3940
4041
mounted() {
4142
// this.startPoller()
42-
setTimeout(() => {
43-
if (this.poller) {
44-
clearInterval(this.poller)
45-
}
46-
}, 60 * 1000 * 60)
43+
setTimeout(
44+
() => {
45+
if (this.poller) {
46+
clearInterval(this.poller)
47+
}
48+
},
49+
60 * 1000 * 60,
50+
)
4751
}
4852
4953
beforeDestroy(): void {
@@ -61,7 +65,7 @@ export default class DefaultLayout extends Vue {
6165
setAuthHeader((await this.$fire.auth.currentUser?.getIdToken()) ?? '')
6266
promises.push(
6367
this.$store.dispatch('loadThreads'),
64-
this.$store.dispatch('getHeartbeat')
68+
this.$store.dispatch('getHeartbeat'),
6569
)
6670
}
6771
@@ -73,8 +77,8 @@ export default class DefaultLayout extends Vue {
7377
promises.push(
7478
this.$store.dispatch(
7579
'loadThreadMessages',
76-
this.$store.getters.getThread.id
77-
)
80+
this.$store.getters.getThread.id,
81+
),
7882
)
7983
}
8084
await Promise.all(promises)

web/middleware/auth.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Context, Middleware } from '@nuxt/types'
22

33
const authMiddleware: Middleware = (context: Context) => {
44
if (context.store.getters.getAuthUser === null) {
5-
if (context.store.getters.getNextRoute) {
6-
context.redirect('/login', { to: context.route.path })
7-
context.store.dispatch('setNextRoute', null)
8-
}
5+
context.redirect('/login', { to: context.route.path })
96
}
107
}
118

web/middleware/guest.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import { Context, Middleware } from '@nuxt/types'
22

33
const guestMiddleware: Middleware = (context: Context) => {
44
if (context.store.getters.getAuthUser !== null) {
5-
if (context.store.getters.getNextRoute) {
6-
context.redirect(context.store.getters.getNextRoute)
7-
context.store.dispatch('setNextRoute', null)
8-
}
95
context.redirect('/threads')
106
}
117
}

web/middleware/user.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

web/nuxt.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default {
112112
persistence: 'local', // default
113113
initialize: {
114114
onAuthStateChangedAction: 'onAuthStateChanged',
115-
onIdTokenChangedAction: 'onAuthStateChanged',
115+
onIdTokenChangedAction: 'onIdTokenChanged',
116116
subscribeManually: false,
117117
},
118118
ssr: false,
@@ -148,10 +148,6 @@ export default {
148148
},
149149
},
150150

151-
router: {
152-
middleware: ['user'],
153-
},
154-
155151
sitemap: {
156152
hostname: 'https://httpsms.com',
157153
gzip: true,

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"jest": "^27.4.4",
6363
"lint-staged": "^13.2.0",
6464
"postcss-html": "^1.5.0",
65-
"prettier": "^2.8.4",
65+
"prettier": "3.0.0-alpha.6",
6666
"stylelint": "^14.16.1",
6767
"stylelint-config-prettier": "^9.0.5",
6868
"stylelint-config-recommended-vue": "^1.1.0",

web/pages/billing/index.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<template>
2-
<v-container fluid class="pa-0" :fill-height="$vuetify.breakpoint.lgAndUp">
2+
<v-container
3+
fluid
4+
class="px-0 pt-0"
5+
:fill-height="$vuetify.breakpoint.lgAndUp"
6+
>
37
<div class="w-full h-full">
48
<v-app-bar height="60" :dense="$vuetify.breakpoint.mdAndDown">
5-
<v-btn icon to="/">
9+
<v-btn icon to="/threads">
610
<v-icon>{{ mdiArrowLeft }}</v-icon>
711
</v-btn>
812
<v-toolbar-title>
@@ -45,7 +49,7 @@
4549
Your next bill is for <b>${{ plan.price }}</b> on
4650
<b>{{
4751
new Date(
48-
$store.getters.getUser.subscription_renews_at
52+
$store.getters.getUser.subscription_renews_at,
4953
).toLocaleDateString()
5054
}}</b>
5155
</p>
@@ -60,7 +64,7 @@
6064
You will be downgraded to the <b>FREE</b> plan on
6165
<b>{{
6266
new Date(
63-
$store.getters.getUser.subscription_ends_at
67+
$store.getters.getUser.subscription_ends_at,
6468
).toLocaleDateString()
6569
}}</b>
6670
</p>
@@ -112,7 +116,7 @@
112116
of the current billing period on
113117
<b>{{
114118
new Date(
115-
$store.getters.getUser.subscription_renews_at
119+
$store.getters.getUser.subscription_renews_at,
116120
).toLocaleDateString()
117121
}}</b>
118122
</p>
@@ -395,7 +399,7 @@ export default Vue.extend({
395399
plan(): PaymentPlan {
396400
return this.plans.find(
397401
(x) =>
398-
x.id === (this.$store.getters.getUser?.subscription_name || 'free')
402+
x.id === (this.$store.getters.getUser?.subscription_name || 'free'),
399403
)!
400404
},
401405
isOnFreePlan(): boolean {
@@ -418,12 +422,6 @@ export default Vue.extend({
418422
},
419423
},
420424
async mounted() {
421-
if (!this.$store.getters.getAuthUser) {
422-
await this.$store.dispatch('setNextRoute', this.$route.path)
423-
await this.$router.push({ name: 'index' })
424-
setTimeout(this.loadData, 2000)
425-
return
426-
}
427425
await this.loadData()
428426
},
429427

0 commit comments

Comments
 (0)