Skip to content

Commit e036310

Browse files
authored
Merge pull request #272 from Seluj78/270-register-route-connect-backend
270 register route connect backend
2 parents 07359db + 58d3b74 commit e036310

File tree

6 files changed

+82
-10
lines changed

6 files changed

+82
-10
lines changed

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ services:
8383
build:
8484
context: .
8585
dockerfile: frontend.Dockerfile
86-
env_file:
87-
- .env.docker
8886
volumes:
8987
- './frontend:/frontend'
9088
- '/frontend/node_modules'

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: '',

frontend/src/views/auth/SignUp.vue

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22
<!-- eslint-disable max-len -->
33
<div class="auth-container">
4+
<div class="auth-sub-container-error mb-4" v-if="error.happened">
5+
<h1 class="auth-sub-container-error-message">{{error.message}}</h1>
6+
</div>
47
<div class="auth-sub-container">
58
<div class="auth-sub-container-content" v-if="!confirmationEmailSent">
69
<div class="flex justify-center items-center">
@@ -13,11 +16,11 @@
1316
<ValidationObserver v-slot="{ handleSubmit, invalid }">
1417
<form @submit.prevent="handleSubmit(onSubmit)" class="mt-4">
1518
<ValidationProvider name="First Name" rules="required|alpha|max:20" v-slot="{errors}">
16-
<input type="text" placeholder="First Name" v-model="formData.firstName" class="matcha-input">
19+
<input type="text" placeholder="First Name" v-model="formData.first_name" class="matcha-input">
1720
<span class="matcha-input-error">{{ errors[0] }}</span>
1821
</ValidationProvider>
1922
<ValidationProvider name="Last Name" rules="required|alpha|max:20" v-slot="{errors}">
20-
<input type="text" placeholder="Last Name" v-model="formData.lastName" class="matcha-input">
23+
<input type="text" placeholder="Last Name" v-model="formData.last_name" class="matcha-input">
2124
<span class="matcha-input-error">{{ errors[0] }}</span>
2225
</ValidationProvider>
2326
<ValidationProvider name="Email" rules="required|email|max:50" v-slot="{errors}">
@@ -55,13 +58,17 @@
5558
export default {
5659
data: () => ({
5760
formData: {
58-
firstName: '',
59-
lastName: '',
61+
first_name: '',
62+
last_name: '',
6063
email: '',
6164
username: '',
6265
password: '',
6366
},
6467
confirmationEmailSent: false,
68+
error: {
69+
happened: false,
70+
message: '',
71+
},
6572
}),
6673
methods: {
6774
passwordErrorHandler(error) {
@@ -70,8 +77,25 @@ export default {
7077
}
7178
return 'This password is too easy to guess';
7279
},
73-
onSubmit() {
74-
this.confirmationEmailSent = true;
80+
async onSubmit() {
81+
try {
82+
this.clearError();
83+
await this.signUpUser(this.formData);
84+
this.confirmationEmailSent = true;
85+
} catch (error) {
86+
this.displayError(this.$errorMessenger(error));
87+
}
88+
},
89+
async signUpUser(user) {
90+
await this.$http.post('/auth/register', user);
91+
},
92+
clearError() {
93+
this.error.message = '';
94+
this.error.happened = false;
95+
},
96+
displayError(message) {
97+
this.error.message = message;
98+
this.error.happened = true;
7599
},
76100
},
77101
};

0 commit comments

Comments
 (0)