mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-30 00:28:02 -04:00
[admin] easier impersonation for debugging
This commit is contained in:
parent
476f44da44
commit
71b552bf49
@ -116,6 +116,10 @@
|
||||
pronouns.page/u/{{user.username}}
|
||||
</span>
|
||||
</a>
|
||||
<a v-if="$isGranted('*')" href="#"
|
||||
class="list-group-item list-group-item-action list-group-item-hoverable small"
|
||||
@click.prevent="impersonate()"><Icon v="user-secret"/> Impersonate
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -274,6 +278,13 @@
|
||||
|
||||
return bestKey >= 0 ? best[bestKey].slice(0, 3) : [];
|
||||
},
|
||||
async impersonate() {
|
||||
const { token } = await this.$axios.$get(`/admin/impersonate/${encodeURIComponent(this.username)}`);
|
||||
this.$cookies.set('impersonator', this.$cookies.get('token'));
|
||||
this.$cookies.set('token', token);
|
||||
await this.$router.push('/' + this.config.user.route);
|
||||
setTimeout(() => window.location.reload(), 500);
|
||||
},
|
||||
},
|
||||
head() {
|
||||
return head({
|
||||
|
@ -612,7 +612,12 @@ router.get('/admin/impersonate/:email', handleErrorAsync(async (req, res) => {
|
||||
return res.status(401).json({error: 'Unauthorised'});
|
||||
}
|
||||
|
||||
return res.json({token: await issueAuthentication(req.db, {email: req.params.email})});
|
||||
let email = req.params.email;
|
||||
if (!email.includes('@')) {
|
||||
email = (await req.db.get(SQL`SELECT email FROM users WHERE usernameNorm = ${normalise(email)}`)).email;
|
||||
}
|
||||
|
||||
return res.json({token: await issueAuthentication(req.db, {email: email})});
|
||||
}));
|
||||
|
||||
export default router;
|
||||
|
Loading…
x
Reference in New Issue
Block a user