Created
April 27, 2021 00:49
-
-
Save susanBuck/d987111d80fb3791ccd50e8e2b720ba2 to your computer and use it in GitHub Desktop.
LoginAs.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<p>Login as: {{ id }}</p> | |
<p>Response: {{ response }}</p> | |
</div> | |
</template> | |
<script> | |
import { axios } from "@/common/app.js"; | |
export default { | |
props: ["id"], | |
data() { | |
return { | |
response: null, | |
}; | |
}, | |
mounted() { | |
this.login(); | |
}, | |
methods: { | |
login() { | |
axios.post("login-as", { id: this.id }).then((response) => { | |
if (response.data.authenticated) { | |
this.$store.commit("setUser", response.data.user); | |
} else { | |
this.response = response.data; | |
this.errors = response.data.errors; | |
} | |
}); | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment