Skip to content

Instantly share code, notes, and snippets.

@susanBuck
Created April 27, 2021 00:49
Show Gist options
  • Save susanBuck/d987111d80fb3791ccd50e8e2b720ba2 to your computer and use it in GitHub Desktop.
Save susanBuck/d987111d80fb3791ccd50e8e2b720ba2 to your computer and use it in GitHub Desktop.
LoginAs.vue
<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