Skip to content

Commit 58d3b74

Browse files
committed
verify registration hooked with backend
1 parent 9395c24 commit 58d3b74

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

frontend/src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import SignUp from '../views/auth/SignUp.vue';
55
import SignIn from '../views/auth/SignIn.vue';
66
import ForgotPassword from '../views/auth/ForgotPassword.vue';
77
import AccountVerified from '../views/auth/AccountVerified.vue';
8+
import AccountVerifiedError from '../views/auth/AccountVerifiedError.vue';
89
import ResetPassword from '../views/auth/ResetPassword.vue';
910
import ResetPasswordError from '../views/auth/ResetPasswordError.vue';
1011

@@ -46,6 +47,11 @@ const routes = [
4647
name: 'AccountVerified',
4748
component: AccountVerified,
4849
},
50+
{
51+
path: '/accounts/verify/error',
52+
name: 'AccountVerifiedError',
53+
component: AccountVerifiedError,
54+
},
4955
];
5056

5157
const router = new VueRouter({

frontend/src/views/auth/AccountVerified.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<!-- eslint-disable max-len -->
3-
<div class="auth-container">
3+
<div class="auth-container" v-if="verified">
44
<div class="auth-sub-container">
55
<div class="auth-sub-container-content">
66
<h1 class="auth-sub-container-content-heading">You are now verified</h1>
@@ -13,6 +13,30 @@
1313
<script>
1414
1515
export default {
16+
data: () => ({
17+
verified: false,
18+
}),
19+
async created() {
20+
try {
21+
await this.checkToken();
22+
await this.verifyUser();
23+
this.verified = true;
24+
} catch (error) {
25+
await this.$router.push('/accounts/verify/error');
26+
}
27+
},
28+
methods: {
29+
async checkToken() {
30+
const { token } = this.$route.query;
31+
if (!token) {
32+
await this.$router.push('/accounts/verify/error');
33+
}
34+
},
35+
async verifyUser() {
36+
const { token } = this.$route.query;
37+
await this.$http.post(`/auth/confirm/${token}`, {});
38+
},
39+
},
1640
};
1741
1842
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<!-- eslint-disable max-len -->
3+
<div class="auth-container">
4+
<div class="auth-sub-container">
5+
<div class="auth-sub-container-content">
6+
<img src="../../assets/auth/error.png" class="h-12">
7+
<h1 class="auth-sub-container-content-heading">Something is wrong</h1>
8+
<h1 class="text-sm text-gray-matcha text-center">Either user has been verified already or this request is invalid</h1>
9+
<router-link to="/accounts/signin" class="auth-sub-container-content-link mt-4">Sign in</router-link>
10+
</div>
11+
</div>
12+
<div class="auth-sub-container-thinner mt-4">
13+
<div class="auth-sub-container-content">
14+
<router-link to="/accounts/signup" class="auth-sub-container-content-link">Sign up</router-link>
15+
</div>
16+
</div>
17+
</div>
18+
</template>

frontend/src/views/auth/ResetPassword.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<!-- eslint-disable max-len -->
3-
<div class="auth-container">
3+
<div class="auth-container" v-if="tokenIsValid">
44
<div class="auth-sub-container-error" v-if="error.happened">
55
<h1 class="auth-sub-container-error-message">{{error.message}}</h1>
66
</div>
@@ -43,8 +43,10 @@
4343
export default {
4444
async created() {
4545
await this.checkToken();
46+
this.tokenIsValid = true;
4647
},
4748
data: () => ({
49+
tokenIsValid: false,
4850
formData: {
4951
password: '',
5052
passwordRepeat: '',

0 commit comments

Comments
 (0)