Improve login/logout
Extract mutation types to mutation-types.js
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
<script>
|
||||
import { LOGIN_SUCCESS } from "../store/mutation-types";
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
dashboard () {
|
||||
@ -25,7 +27,8 @@ export default {
|
||||
.then(x => x.json())
|
||||
.then(x => {
|
||||
this.$data.error = ""
|
||||
this.$store.commit("setToken", x.token);
|
||||
this.$store.commit(LOGIN_SUCCESS, x);
|
||||
this.$router.replace("/dashboard");
|
||||
})
|
||||
.catch(x => this.$data.error = ["The entered credentials are invalid!"]);
|
||||
|
||||
|
@ -58,7 +58,8 @@ $(document).ready(function () {
|
||||
</form>
|
||||
{{end}}-->
|
||||
|
||||
<script>
|
||||
<script>import { LOGIN_SUCCESS } from "../store/mutation-types";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -76,7 +77,7 @@ export default {
|
||||
.then(x => x.json())
|
||||
.then(x => {
|
||||
this.$data.error = ""
|
||||
this.$store.commit("setToken", x.token);
|
||||
this.$store.commit(LOGIN_SUCCESS, x.token);
|
||||
})
|
||||
.catch(x => this.$data.error = ["Something went wrong!"]);
|
||||
|
||||
|
Reference in New Issue
Block a user