Skip to content

Commit 357dd76

Browse files
committed
Prevented self edit of active/superuser/verified flags
1 parent c4d2eb6 commit 357dd76

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/lib/components/admin/UserEditor.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script>
22
import { goto } from '$app/navigation';
3+
import { page } from '$app/stores';
34
import { nullifyEmptyStrings, removeNullValues } from '$lib/common/component_utilities';
45
import { displayStandardErrorAlert, getValidationMessagesMap } from '$lib/common/errors';
56
import { onMount } from 'svelte';
@@ -166,7 +167,7 @@
166167
<span class="invalid-feedback">{validationErrors['username']}</span>
167168
</div>
168169
</div>
169-
{#if user.id}
170+
{#if user.id && user.id !== $page.data.userInfo.id}
170171
<div class="row mb-3">
171172
<div class="col-sm-9 offset-sm-3">
172173
<div class="form-check">

tests/users_crud.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ test('Create, update and delete a user', async ({ page }) => {
157157
verifyChecked(userRow, 4, false);
158158
verifyChecked(userRow, 5, true);
159159
});
160+
161+
await test.step("Verify that the admin can't edit his/her superuser status", async () => {
162+
await page.goto(`/admin/users/1/edit`);
163+
expect(await page.locator('input[type="checkbox"]').count()).toEqual(0);
164+
});
160165
});
161166

162167
/**

0 commit comments

Comments
 (0)