view schema/updates/1312/01.hide_sys_admins.sql @ 5095:e21cbb9768a2

Prevent duplicate fairway areas In principal, there can be only one or no fairway area at each point on the map. Since polygons from real data will often be topologically inexact, just disallow equal geometries. This will also help to avoid importing duplicates with concurrent imports, once the history of fairway dimensions will be preserved.
author Tom Gottfried <tom@intevation.de>
date Wed, 25 Mar 2020 18:10:02 +0100
parents dfd990a4ac64
children
line wrap: on
line source

CREATE OR REPLACE VIEW users.list_users WITH (security_barrier) AS
    SELECT
        r.rolname,
        p.username,
        CAST('' AS varchar) AS pw,
        p.country,
        p.map_extent,
        p.email_address
    FROM internal.user_profiles p
        JOIN pg_roles u ON p.username = u.rolname
        JOIN pg_auth_members a ON u.oid = a.member
        JOIN pg_roles r ON a.roleid = r.oid
    WHERE p.username = current_user
        OR pg_has_role('waterway_admin', 'MEMBER')
            AND p.country = (
                SELECT country FROM internal.user_profiles
                    WHERE username = current_user)
            AND r.rolname <> 'sys_admin'
        OR pg_has_role('sys_admin', 'MEMBER')