File tree Expand file tree Collapse file tree 9 files changed +197
-15
lines changed
store/modules/authentication Expand file tree Collapse file tree 9 files changed +197
-15
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <fragment >
3
+ <v-btn
4
+ v-for =" ({ icon, value, click }, index) in buttons"
5
+ color =" deep-purple accent-4"
6
+ text
7
+ @click =" click"
8
+ :key =" index"
9
+ >
10
+ <v-icon left >{{ icon }}</v-icon >
11
+ {{ value }}
12
+ </v-btn >
13
+ </fragment >
14
+ </template >
15
+
16
+ <script >
17
+ export default {
18
+ name: ' FormButtons' ,
19
+ props: {
20
+ buttons: Array ,
21
+ },
22
+ };
23
+ </script >
24
+
25
+ <style scoped>
26
+
27
+ </style >
Original file line number Diff line number Diff line change 16
16
17
17
<script >
18
18
export default {
19
- name: ' TestFields ' ,
19
+ name: ' FormFields ' ,
20
20
props: {
21
21
fields: Array ,
22
22
},
Original file line number Diff line number Diff line change 1
1
export { default as HelloWorld } from './HelloWorld' ;
2
- export { default as TextFields } from './TextFields' ;
3
2
export { default as Card } from './Card' ;
4
3
export { default as FormAlerts } from './FormAlerts' ;
4
+ export { default as FormFields } from './FormFields' ;
5
+ export { default as FormButtons } from './FormButtons' ;
Original file line number Diff line number Diff line change 4
4
<span @click =" $router.push('/')" >Open Rank</span >
5
5
</v-toolbar-title >
6
6
<v-spacer ></v-spacer >
7
- <v-btn text >
7
+ <v-btn text to = " /login " >
8
8
<span class =" mr-2" >Login</span >
9
9
</v-btn >
10
10
<v-btn text to =" /register" >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Router from 'vue-router';
3
3
import Home from '../views/Home' ;
4
4
import About from '../views/About' ;
5
5
import Register from '../views/Register' ;
6
+ import Login from '../views/Login' ;
6
7
7
8
Vue . use ( Router ) ;
8
9
@@ -25,5 +26,10 @@ export default new Router({
25
26
name : 'register' ,
26
27
component : Register ,
27
28
} ,
29
+ {
30
+ path : '/login' ,
31
+ name : 'login' ,
32
+ component : Login ,
33
+ } ,
28
34
] ,
29
35
} ) ;
Original file line number Diff line number Diff line change 1
1
import register from './register' ;
2
+ import login from './login' ;
2
3
3
4
export default {
4
5
namespaced : true ,
@@ -13,5 +14,6 @@ export default {
13
14
} ,
14
15
modules : {
15
16
register,
17
+ login,
16
18
} ,
17
19
} ;
Original file line number Diff line number Diff line change
1
+ import HTTP from '../../../http' ;
2
+
3
+ export default {
4
+ namespaced : true ,
5
+ strict : true ,
6
+ state : {
7
+ email : '' ,
8
+ password : '' ,
9
+ successMsg : '' ,
10
+ } ,
11
+ mutations : {
12
+ setEmail ( state , email ) {
13
+ state . email = email ;
14
+ } ,
15
+ setPassword ( state , password ) {
16
+ state . password = password ;
17
+ } ,
18
+ setSuccessMsg ( state , message ) {
19
+ state . successMsg = message ;
20
+ } ,
21
+ } ,
22
+ actions : {
23
+ async login ( {
24
+ commit,
25
+ state : {
26
+ email,
27
+ password,
28
+ } ,
29
+ } ) {
30
+ await HTTP ( ) . post ( '/login' , {
31
+ email,
32
+ password,
33
+ } ) . then ( ( { data : { message } } ) => {
34
+ commit ( 'setSuccessMsg' , message ) ;
35
+ } ) ;
36
+ } ,
37
+ } ,
38
+ } ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <v-row align =" start" justify =" center" >
3
+ <v-col sm =" 7" >
4
+ <card >
5
+ <template v-slot :title >Login</template >
6
+ <v-form >
7
+ <form-alerts :alerts =" alerts" ></form-alerts >
8
+ <form-fields :fields =" fields" ></form-fields >
9
+ </v-form >
10
+ <template v-slot :actions >
11
+ <form-buttons :buttons =" buttons" ></form-buttons >
12
+ </template >
13
+ </card >
14
+ </v-col >
15
+ </v-row >
16
+ </template >
17
+
18
+ <script >
19
+ import { createNamespacedHelpers } from ' vuex' ;
20
+
21
+ import {
22
+ Card ,
23
+ FormFields ,
24
+ FormAlerts ,
25
+ FormButtons ,
26
+ } from ' ../components' ;
27
+
28
+ const { mapState , mapMutations , mapActions } = createNamespacedHelpers (' authentication/login' );
29
+
30
+ export default {
31
+ name: ' Login' ,
32
+ data () {
33
+ return {
34
+ };
35
+ },
36
+ computed: {
37
+ ... mapState ([
38
+ ' email' ,
39
+ ' password' ,
40
+ ' successMsg' ,
41
+ ]),
42
+ alerts () {
43
+ return [
44
+ {
45
+ type: ' success' ,
46
+ message: this .successMsg ,
47
+ },
48
+ ];
49
+ },
50
+ fields () {
51
+ return [
52
+ {
53
+ label: ' Email' ,
54
+ placeholder: ' Enter Email' ,
55
+ type: ' email' ,
56
+ icon: ' mdi-email' ,
57
+ value: this .email ,
58
+ input: this .setEmail ,
59
+ },
60
+ {
61
+ label: ' Password' ,
62
+ placeholder: ' Enter Password' ,
63
+ type: ' password' ,
64
+ icon: ' mdi-lock' ,
65
+ value: this .password ,
66
+ input: this .setPassword ,
67
+ },
68
+ ];
69
+ },
70
+ buttons () {
71
+ return [
72
+ {
73
+ icon: ' mdi-fingerprint' ,
74
+ value: ' Login' ,
75
+ click: this .login ,
76
+ },
77
+ ];
78
+ },
79
+ },
80
+ methods: {
81
+ ... mapMutations ([
82
+ ' setEmail' ,
83
+ ' setPassword' ,
84
+ ]),
85
+ ... mapActions ([
86
+ ' login' ,
87
+ ]),
88
+ },
89
+ components: {
90
+ Card,
91
+ FormFields,
92
+ FormAlerts,
93
+ FormButtons,
94
+ },
95
+ };
96
+ </script >
97
+
98
+ <style scoped>
99
+
100
+ </style >
Original file line number Diff line number Diff line change 5
5
<template v-slot :title >Register</template >
6
6
<v-form >
7
7
<form-alerts :alerts =" alerts" ></form-alerts >
8
- <text -fields :fields =" fields" ></text -fields >
8
+ <form -fields :fields =" fields" ></form -fields >
9
9
</v-form >
10
10
<template v-slot :actions >
11
- <v-btn
12
- color =" deep-purple accent-4"
13
- text
14
- @click =" register"
15
- >
16
- <v-icon left >mdi-account</v-icon >
17
- Register
18
- </v-btn >
11
+ <form-buttons :buttons =" buttons" ></form-buttons >
19
12
</template >
20
13
</card >
21
14
</v-col >
25
18
<script >
26
19
import { createNamespacedHelpers } from ' vuex' ;
27
20
28
- import { Card , TextFields , FormAlerts } from ' ../components' ;
21
+ import {
22
+ Card ,
23
+ FormFields ,
24
+ FormAlerts ,
25
+ FormButtons ,
26
+ } from ' ../components' ;
29
27
30
28
const { mapState , mapMutations , mapActions } = createNamespacedHelpers (' authentication/register' );
31
29
@@ -63,7 +61,7 @@ export default {
63
61
},
64
62
{
65
63
label: ' Email' ,
66
- placeholder: ' Enter your email address ' ,
64
+ placeholder: ' Enter Email ' ,
67
65
type: ' email' ,
68
66
icon: ' mdi-email' ,
69
67
value: this .email ,
@@ -87,6 +85,15 @@ export default {
87
85
},
88
86
];
89
87
},
88
+ buttons () {
89
+ return [
90
+ {
91
+ icon: ' mdi-account' ,
92
+ value: ' Register' ,
93
+ click: this .register ,
94
+ },
95
+ ];
96
+ },
90
97
},
91
98
methods: {
92
99
... mapMutations ([
@@ -101,8 +108,9 @@ export default {
101
108
},
102
109
components: {
103
110
Card,
104
- TextFields ,
111
+ FormFields ,
105
112
FormAlerts,
113
+ FormButtons,
106
114
},
107
115
};
108
116
</script >
You can’t perform that action at this time.
0 commit comments