Mercurial > gemma
comparison src/views/Login.vue @ 10:361ae8211991 vue-cli
refactored to component local state
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 18 Jun 2018 12:11:35 +0200 |
parents | ee6d3836014e |
children | e0b5dd98665e |
comparison
equal
deleted
inserted
replaced
9:ee6d3836014e | 10:361ae8211991 |
---|---|
55 name: "login", | 55 name: "login", |
56 data() { | 56 data() { |
57 return { | 57 return { |
58 username: "", | 58 username: "", |
59 password: "", | 59 password: "", |
60 submitted: false | 60 submitted: false, |
61 loginFailed: false | |
61 }; | 62 }; |
62 }, | 63 }, |
63 computed: { | 64 computed: { |
64 ...mapGetters("application", ["appTitle", "loginFailed", "secondaryLogo"]), | 65 ...mapGetters("application", ["appTitle", "secondaryLogo"]), |
65 ...mapGetters("i18n", [ | 66 ...mapGetters("i18n", [ |
66 "signinHeader", | 67 "signinHeader", |
67 "emailLabel", | 68 "emailLabel", |
68 "passwordLabel", | 69 "passwordLabel", |
69 "loginButtonLabel", | 70 "loginButtonLabel", |
76 this.submitted = true; | 77 this.submitted = true; |
77 const { username, password } = this; | 78 const { username, password } = this; |
78 this.$store | 79 this.$store |
79 .dispatch("user/login", { username, password }) | 80 .dispatch("user/login", { username, password }) |
80 .then(() => { | 81 .then(() => { |
81 this.$store.commit("application/loginSuccess"); | 82 this.loginFailed = false; |
82 this.$router.push("/"); | 83 this.$router.push("/"); |
83 }) | 84 }) |
84 .catch(() => { | 85 .catch(() => { |
85 this.$store.commit("application/loginError"); | 86 this.loginFailed = true; |
86 this.submitted = false; | 87 this.submitted = false; |
87 }); | 88 }); |
88 } | 89 } |
89 } | 90 } |
90 }; | 91 }; |