diff options
Diffstat (limited to 'src/views/Register.vue')
-rw-r--r-- | src/views/Register.vue | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/views/Register.vue b/src/views/Register.vue index c03f5fd..eb382c5 100644 --- a/src/views/Register.vue +++ b/src/views/Register.vue | |||
@@ -7,9 +7,8 @@ | |||
7 | 7 | ||
8 | <input type="submit" value="Register!"> | 8 | <input type="submit" value="Register!"> |
9 | </form> | 9 | </form> |
10 | <p v-for="(mess, key) in messages" :key="key">{{mess}}</p> | ||
11 | 10 | ||
12 | <router-link to="/login">Already have account?</router-link> | 11 | <router-link to="/login">Already have an account?</router-link> |
13 | 12 | ||
14 | </div> | 13 | </div> |
15 | </template> | 14 | </template> |
@@ -23,7 +22,6 @@ export default { | |||
23 | login: "", | 22 | login: "", |
24 | password: "", | 23 | password: "", |
25 | repeat_password: "", | 24 | repeat_password: "", |
26 | messages: [] | ||
27 | } | 25 | } |
28 | }, | 26 | }, |
29 | methods: { | 27 | methods: { |
@@ -32,27 +30,28 @@ export default { | |||
32 | 30 | ||
33 | e.preventDefault() | 31 | e.preventDefault() |
34 | if(this.password !== this.repeat_password){ | 32 | if(this.password !== this.repeat_password){ |
35 | this.messages.push("Passwords not equals") | 33 | this.$notify({ |
34 | type: 'warn', | ||
35 | text: 'Passwords not equals', | ||
36 | }) | ||
36 | this.password = "" | 37 | this.password = "" |
37 | this.repeat_password = "" | 38 | this.repeat_password = "" |
38 | 39 | ||
39 | return null | 40 | return null |
40 | } | 41 | } |
41 | 42 | ||
42 | const data = { | 43 | const register_data = { |
43 | "username": this.login, | 44 | "username": this.login, |
44 | "password": this.password | 45 | "password": this.password |
45 | } | 46 | } |
46 | 47 | ||
47 | try { | 48 | const { status } = await AuthService.register(register_data) |
48 | await AuthService.register(data) | 49 | if (status === 200) { |
49 | this.messages.push("Success!") | 50 | this.$notify({ |
50 | }catch (error) { | 51 | type: 'success', |
51 | if(error.response.data.username) | 52 | text:'Register success, you can now login.!' |
52 | this.messages.push(error.response.data.username[0]) | 53 | }) |
53 | if (error.response.data.password) | 54 | this.$router.push('/login') |
54 | this.messages.push(error.response.data.password[0]) | ||
55 | |||
56 | } | 55 | } |
57 | } | 56 | } |
58 | }, | 57 | }, |