2022-09-20 19:59:52 +00:00
|
|
|
<template>
|
2022-11-08 16:44:04 +00:00
|
|
|
<div>
|
|
|
|
<h3 class="font-semibold text-2xl text-gray-900">Admin settings</h3>
|
|
|
|
<small class="text-gray-600">Manage settings.</small>
|
|
|
|
|
|
|
|
|
|
|
|
<h3 class="mt-3 text-lg font-semibold mb-4">
|
2022-09-20 19:59:52 +00:00
|
|
|
Tools
|
|
|
|
</h3>
|
2022-11-08 16:44:04 +00:00
|
|
|
<div class="flex flex-wrap mb-5">
|
2022-09-20 19:59:52 +00:00
|
|
|
<a href="/stats">
|
|
|
|
<v-button class="mx-1" color="gray" shade="lighter">
|
|
|
|
Stats
|
|
|
|
</v-button>
|
|
|
|
</a>
|
|
|
|
<a href="/horizon">
|
|
|
|
<v-button class="mx-1" color="gray" shade="lighter">
|
|
|
|
Horizon
|
|
|
|
</v-button>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<h3 class="text-lg font-semibold mb-4">
|
|
|
|
Impersonate User
|
|
|
|
</h3>
|
|
|
|
<form @submit.prevent="impersonate" @keydown="form.onKeydown($event)">
|
|
|
|
<!-- Password -->
|
|
|
|
<text-input name="identifier" :form="form" label="Identifier"
|
|
|
|
:required="true" help="User Id, User Email or Form Slug"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<!-- Submit Button -->
|
2022-11-08 16:44:04 +00:00
|
|
|
<v-button :loading="loading" class="mt-4">Impersonate User</v-button>
|
2022-09-20 19:59:52 +00:00
|
|
|
</form>
|
2022-11-08 16:44:04 +00:00
|
|
|
</div>
|
2022-09-20 19:59:52 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Form from 'vform'
|
|
|
|
import axios from 'axios'
|
2022-12-22 10:55:17 +00:00
|
|
|
import SeoMeta from '../../mixins/seo-meta'
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
export default {
|
2022-10-17 13:42:04 +00:00
|
|
|
components: { },
|
2022-09-20 19:59:52 +00:00
|
|
|
middleware: 'admin',
|
|
|
|
scrollToTop: false,
|
2022-12-22 10:55:17 +00:00
|
|
|
mixins: [SeoMeta],
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
data: () => ({
|
2022-12-22 10:55:17 +00:00
|
|
|
metaTitle: 'Admin',
|
2022-09-20 19:59:52 +00:00
|
|
|
form: new Form({
|
|
|
|
identifier: ''
|
|
|
|
}),
|
|
|
|
loading: false
|
|
|
|
}),
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async impersonate () {
|
|
|
|
this.loading = true
|
|
|
|
this.$store.commit('auth/startImpersonating')
|
|
|
|
axios.get('/api/admin/impersonate/' + encodeURI(this.form.identifier)).then(async (response) => {
|
|
|
|
this.loading = false
|
|
|
|
|
|
|
|
// Save the token.
|
|
|
|
this.$store.dispatch('auth/saveToken', {
|
|
|
|
token: response.data.token,
|
|
|
|
remember: false
|
|
|
|
})
|
|
|
|
|
|
|
|
// Fetch the user.
|
|
|
|
await this.$store.dispatch('auth/fetchUser')
|
|
|
|
|
|
|
|
// Redirect to the dashboard.
|
|
|
|
this.$store.commit('open/workspaces/set', [])
|
|
|
|
this.$router.push({ name: 'home' })
|
|
|
|
}).catch((error) => {
|
|
|
|
this.alertError(error.response.data.message)
|
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
|
|
|
|
// this.form.reset()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|