implemented user impersonization
This commit is contained in:
@@ -13,12 +13,24 @@
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
const json = await resp.json();
|
||||
for (let user of json) users.push(user);
|
||||
for (let u of json) users.push(u);
|
||||
}
|
||||
});
|
||||
|
||||
async function impersonate(userId){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/${userId}/impersonate`;
|
||||
const resp = await fetch(url,{
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (resp.ok){
|
||||
const json = await resp.json();
|
||||
for (let key of Object.keys(json)) user[key] = json[key];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
<fieldset tabindex="0">
|
||||
<legend>{t('user.list')}</legend>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -38,6 +50,9 @@
|
||||
<td>{u.email}</td>
|
||||
<td>{u.language}</td>
|
||||
<td>
|
||||
{#if user.permissions.includes('IMPERSONATE')}
|
||||
<button onclick={() => impersonate(u.id)}>{t('user.impersonate')}</button>
|
||||
{/if}
|
||||
{#if user.permissions.includes('UPDATE_USERS')}
|
||||
<button onclick={() => router.navigate(`/user/${u.id}/edit`)}>{t('user.edit')}</button>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user