Skip to content

Commit a01e6d7

Browse files
Merge pull request #13 from PierreBrisorgueil/featSignup
feat(auth): add signup ✨
2 parents 9789328 + 0b0b6b2 commit a01e6d7

File tree

3 files changed

+61
-53
lines changed

3 files changed

+61
-53
lines changed

src/modules/auth/stores/auth.store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const actions = {
5252
signup({ commit }, user) {
5353
return new Promise((resolve, reject) => {
5454
commit('auth_request');
55+
console.log(user);
5556
axios({
5657
url: `${api}/${config.api.endPoints.auth}/signup`,
5758
data: user,

src/modules/auth/views/auth.signin.view.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<v-form ref="form" v-model="valid">
88
<v-container>
99
<v-row>
10-
<v-col cols="12" md="4">
10+
<v-col sm="12">
1111
<v-text-field v-model="email" :rules="emailRules" label="E-mail" required></v-text-field>
1212
</v-col>
13-
<v-col cols="12" md="4">
13+
<v-col sm="12">
1414
<v-text-field :type="'password'" v-model="password" label="Password" required></v-text-field>
1515
</v-col>
1616
</v-row>
@@ -20,6 +20,7 @@
2020
</v-row>
2121
</v-container>
2222
</v-form>
23+
<router-link to="/signup">SignUp</router-link> if you have no account yet :) !
2324
</v-card>
2425
</v-row>
2526
</v-col>
@@ -36,12 +37,12 @@ export default {
3637
data() {
3738
return {
3839
valid: false,
39-
email: 'seeduser@localhost.com',
40+
email: '',
4041
emailRules: [
4142
v => !!v || 'E-mail is required',
4243
v => /.+@.+/.test(v) || 'E-mail must be valid',
4344
],
44-
password: 'zHwJKWk6z5Hp7tWFD143EK',
45+
password: '',
4546
};
4647
},
4748
methods: {

src/modules/auth/views/auth.signup.view.vue

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,73 @@
11
<template>
2-
<div>
3-
<form @submit.prevent="signup">
4-
<h1>Sign Up</h1>
5-
<label for="firstname">Firstname</label>
6-
<div>
7-
<input id="firstname" type="text" v-model="firstname" required autofocus />
8-
</div>
9-
10-
<label for="firstname">Lastname</label>
11-
<div>
12-
<input id="lastname" type="text" v-model="lastname" required autofocus />
13-
</div>
14-
15-
<label for="email">E-Mail Address</label>
16-
<div>
17-
<input id="email" type="email" v-model="email" required />
18-
</div>
19-
20-
<label for="password">Password</label>
21-
<div>
22-
<input id="password" type="password" v-model="password" required />
23-
</div>
24-
25-
<label for="password-confirm">Confirm Password</label>
26-
<div>
27-
<input id="password-confirm" type="password" v-model="password_confirmation" required />
28-
</div>
29-
30-
<div>
31-
<button type="submit">Sign Up</button>
32-
</div>
33-
</form>
34-
</div>
2+
<v-container fluid>
3+
<v-row>
4+
<v-col cols="12">
5+
<v-row align="start" justify="center">
6+
<v-card class="ma-4 pa-8" outlined tile width="100%">
7+
<v-form ref="form" v-model="valid">
8+
<v-container>
9+
<v-row>
10+
<v-col md="6" sm="12">
11+
<v-text-field v-model="firstName" label="Firstname" required></v-text-field>
12+
</v-col>
13+
<v-col md="6" sm="12">
14+
<v-text-field v-model="lastName" label="Lastname" required></v-text-field>
15+
</v-col>
16+
<v-col md="12" sm="12">
17+
<v-text-field v-model="email" :rules="emailRules" label="E-mail" required></v-text-field>
18+
</v-col>
19+
<v-col md="12" sm="12">
20+
<v-text-field :type="'password'" v-model="password" label="Password" required></v-text-field>
21+
</v-col>
22+
</v-row>
23+
<v-row>
24+
<v-btn :disabled="!valid" color="success" class="mr-4" @click="validate">Validate</v-btn>
25+
<v-btn color="error" class="mr-4" @click="reset">Reset Form</v-btn>
26+
</v-row>
27+
</v-container>
28+
</v-form>
29+
<router-link to="/signin">SignIn</router-link> if you already have an account :) !
30+
</v-card>
31+
</v-row>
32+
</v-col>
33+
</v-row>
34+
</v-container>
3535
</template>
3636

37+
3738
<script>
3839
/**
3940
* Export default
4041
*/
4142
export default {
4243
data() {
4344
return {
44-
firstname: '',
45-
lastname: '',
45+
valid: false,
46+
firstName: '',
47+
lastName: '',
4648
email: '',
49+
emailRules: [
50+
v => !!v || 'E-mail is required',
51+
v => /.+@.+/.test(v) || 'E-mail must be valid',
52+
],
4753
password: '',
48-
password_confirmation: '',
49-
is_admin: null,
5054
};
5155
},
5256
methods: {
53-
signup() {
54-
const data = {
55-
firstname: this.firstname,
56-
lastname: this.lastname,
57-
email: this.email,
58-
password: this.password,
59-
is_admin: this.is_admin,
60-
};
61-
this.$store
62-
.dispatch('signup', data)
63-
.then(() => this.$router.push('/'))
64-
.catch(err => console.log(err));
57+
validate() {
58+
if (this.$refs.form.validate()) {
59+
const { firstName } = this;
60+
const { lastName } = this;
61+
const { email } = this;
62+
const { password } = this;
63+
this.$store
64+
.dispatch('signup', { email, password, firstName, lastName })
65+
.then(() => this.$router.push('/'))
66+
.catch(err => console.log(err));
67+
}
68+
},
69+
reset() {
70+
this.$refs.form.reset();
6571
},
6672
},
6773
};

0 commit comments

Comments
 (0)