Skip to content

Commit 1c9b794

Browse files
mdouchinGustry
authored andcommitted
Header - Add authenticated user organization in hidden fields
This allows a JavaScript script to get the current user organization and use it in the editing form.
1 parent 7f9a29e commit 1c9b794

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

lizmap/modules/lizmap/templates/user_menu.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<span id="info-user-login" title="{$user->firstname} {$user->lastname}">{$user->login|eschtml}</span>
1212
<span style="display:none" id="info-user-firstname">{$user->firstname}</span>
1313
<span style="display:none" id="info-user-lastname">{$user->lastname}</span>
14+
<span style="display:none" id="info-user-organization">{$user->organization}</span>
1415
</span>
1516
<span class="caret"></span>
1617
</a>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// @ts-check
2+
import { test, expect } from '@playwright/test';
3+
import {ProjectPage} from "./pages/project";
4+
5+
test.describe('Header',
6+
{
7+
tag: ['@readonly'],
8+
},
9+
() => {
10+
11+
test('Login info as user A on the landing page', async ({ browser }) => {
12+
const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' });
13+
const page = await userA.newPage();
14+
await page.goto('index.php');
15+
16+
// Fixme, class "hide" but visible ?
17+
await expect(page.locator("#info-user-login")).toHaveText("user_in_group_a");
18+
await expect(page.locator("#info-user-firstname")).toHaveText("User A");
19+
await expect(page.locator("#info-user-firstname")).toHaveClass("hide");
20+
await expect(page.locator("#info-user-firstname")).toBeVisible();
21+
await expect(page.locator("#info-user-lastname")).toHaveText("Testadiferro");
22+
await expect(page.locator("#info-user-lastname")).toHaveClass("hide");
23+
await expect(page.locator("#info-user-lastname")).toBeVisible();
24+
await expect(page.locator("#info-user-organization")).toHaveText("Make it KISS");
25+
await expect(page.locator("#info-user-organization")).toHaveClass("hide");
26+
await expect(page.locator("#info-user-organization")).toBeVisible();
27+
});
28+
29+
test('Login info as user A on project page', async ({ browser }) => {
30+
const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' });
31+
const userPage = await userA.newPage();
32+
const projectPage = new ProjectPage(userPage, 'world-3857');
33+
await projectPage.open();
34+
35+
await expect(userPage.locator("#info-user-login")).toHaveText("user_in_group_a");
36+
await expect(userPage.locator("#info-user-firstname")).toHaveText("User A");
37+
await expect(userPage.locator("#info-user-firstname")).toHaveClass("hide");
38+
await expect(userPage.locator("#info-user-firstname")).not.toBeVisible();
39+
await expect(userPage.locator("#info-user-lastname")).toHaveText("Testadiferro");
40+
await expect(userPage.locator("#info-user-lastname")).toHaveClass("hide");
41+
await expect(userPage.locator("#info-user-lastname")).not.toBeVisible();
42+
await expect(userPage.locator("#info-user-organization")).toHaveText("Make it KISS");
43+
await expect(userPage.locator("#info-user-organization")).toHaveClass("hide");
44+
await expect(userPage.locator("#info-user-organization")).not.toBeVisible();
45+
});
46+
47+
test('Login info as anonymous on the landing page', async ({ page }) => {
48+
await page.goto('index.php');
49+
await expect(page.locator("#headermenu .login")).toHaveText("Connect");
50+
});
51+
52+
test('Login info as anonymous on project page', async ({ page }) => {
53+
const projectPage = new ProjectPage(page, 'world-3857');
54+
await projectPage.open();
55+
await expect(page.locator("#headermenu .login")).toHaveText("Connect");
56+
});
57+
});

tests/qgis-projects/tests/set_tests_respository_rights.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ INSERT INTO lizmap.jacl2_group(
1313

1414
-- Users
1515
INSERT INTO lizmap.jlx_user(
16-
usr_login, usr_email, usr_password, status, create_date)
16+
usr_login, usr_email, usr_password, status, create_date, firstname, lastname, organization)
1717
VALUES
18-
('user_in_group_a', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW()),
19-
('user_in_group_b', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW()),
20-
('publisher', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW())
18+
('user_in_group_a', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'User A', 'Testadiferro', 'Make it KISS'),
19+
('user_in_group_b', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'User B', 'Testillano', 'Make it KISS'),
20+
('publisher', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'Publisher', 'Testla', 'Make it KISS')
2121
ON CONFLICT DO NOTHING
2222
;
2323

0 commit comments

Comments
 (0)