mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-75: Do not insert duplicate permissions.
This commit is contained in:
@@ -105,12 +105,25 @@
|
|||||||
permission,
|
permission,
|
||||||
connection_group_id
|
connection_group_id
|
||||||
)
|
)
|
||||||
VALUES
|
SELECT DISTINCT
|
||||||
<foreach collection="permissions" item="permission" separator=",">
|
permissions.user_id,
|
||||||
(#{permission.userID,jdbcType=INTEGER},
|
permissions.permission,
|
||||||
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type,
|
permissions.connection_group_id
|
||||||
#{permission.objectIdentifier,jdbcType=INTEGER}::integer)
|
FROM
|
||||||
|
<foreach collection="permissions" item="permission"
|
||||||
|
open="(" separator="UNION ALL" close=")">
|
||||||
|
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
||||||
|
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type AS permission,
|
||||||
|
#{permission.objectIdentifier,jdbcType=INTEGER}::integer AS connection_group_id
|
||||||
</foreach>
|
</foreach>
|
||||||
|
AS permissions
|
||||||
|
WHERE (user_id, permission, connection_group_id) NOT IN (
|
||||||
|
SELECT
|
||||||
|
guacamole_connection_group_permission.user_id,
|
||||||
|
guacamole_connection_group_permission.permission,
|
||||||
|
guacamole_connection_group_permission.connection_group_id
|
||||||
|
FROM guacamole_connection_group_permission
|
||||||
|
);
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
@@ -105,12 +105,25 @@
|
|||||||
permission,
|
permission,
|
||||||
connection_id
|
connection_id
|
||||||
)
|
)
|
||||||
VALUES
|
SELECT DISTINCT
|
||||||
<foreach collection="permissions" item="permission" separator=",">
|
permissions.user_id,
|
||||||
(#{permission.userID,jdbcType=INTEGER},
|
permissions.permission,
|
||||||
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type,
|
permissions.connection_id
|
||||||
#{permission.objectIdentifier,jdbcType=INTEGER}::integer)
|
FROM
|
||||||
|
<foreach collection="permissions" item="permission"
|
||||||
|
open="(" separator="UNION ALL" close=")">
|
||||||
|
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
||||||
|
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type AS permission,
|
||||||
|
#{permission.objectIdentifier,jdbcType=INTEGER}::integer AS connection_id
|
||||||
</foreach>
|
</foreach>
|
||||||
|
AS permissions
|
||||||
|
WHERE (user_id, permission, connection_id) NOT IN (
|
||||||
|
SELECT
|
||||||
|
guacamole_connection_permission.user_id,
|
||||||
|
guacamole_connection_permission.permission,
|
||||||
|
guacamole_connection_permission.connection_id
|
||||||
|
FROM guacamole_connection_permission
|
||||||
|
);
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
@@ -105,12 +105,25 @@
|
|||||||
permission,
|
permission,
|
||||||
sharing_profile_id
|
sharing_profile_id
|
||||||
)
|
)
|
||||||
VALUES
|
SELECT DISTINCT
|
||||||
<foreach collection="permissions" item="permission" separator=",">
|
permissions.user_id,
|
||||||
(#{permission.userID,jdbcType=INTEGER},
|
permissions.permission,
|
||||||
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type,
|
permissions.sharing_profile_id
|
||||||
#{permission.objectIdentifier,jdbcType=INTEGER}::integer)
|
FROM
|
||||||
|
<foreach collection="permissions" item="permission"
|
||||||
|
open="(" separator="UNION ALL" close=")">
|
||||||
|
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
||||||
|
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type AS permission,
|
||||||
|
#{permission.objectIdentifier,jdbcType=INTEGER}::integer AS sharing_profile_id
|
||||||
</foreach>
|
</foreach>
|
||||||
|
AS permissions
|
||||||
|
WHERE (user_id, permission, sharing_profile_id) NOT IN (
|
||||||
|
SELECT
|
||||||
|
guacamole_sharing_profile_permission.user_id,
|
||||||
|
guacamole_sharing_profile_permission.permission,
|
||||||
|
guacamole_sharing_profile_permission.sharing_profile_id
|
||||||
|
FROM guacamole_sharing_profile_permission
|
||||||
|
);
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
@@ -79,11 +79,22 @@
|
|||||||
user_id,
|
user_id,
|
||||||
permission
|
permission
|
||||||
)
|
)
|
||||||
VALUES
|
SELECT DISTINCT
|
||||||
<foreach collection="permissions" item="permission" separator=",">
|
permissions.user_id,
|
||||||
(#{permission.userID,jdbcType=INTEGER},
|
permissions.permission
|
||||||
#{permission.type,jdbcType=VARCHAR}::guacamole_system_permission_type)
|
FROM
|
||||||
|
<foreach collection="permissions" item="permission"
|
||||||
|
open="(" separator="UNION ALL" close=")">
|
||||||
|
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
||||||
|
#{permission.type,jdbcType=VARCHAR}::guacamole_system_permission_type AS permission
|
||||||
</foreach>
|
</foreach>
|
||||||
|
AS permissions
|
||||||
|
WHERE (user_id, permission) NOT IN (
|
||||||
|
SELECT
|
||||||
|
guacamole_system_permission.user_id,
|
||||||
|
guacamole_system_permission.permission
|
||||||
|
FROM guacamole_system_permission
|
||||||
|
);
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
@@ -111,7 +111,11 @@
|
|||||||
permission,
|
permission,
|
||||||
affected_user_id
|
affected_user_id
|
||||||
)
|
)
|
||||||
SELECT permissions.user_id, permissions.permission, guacamole_user.user_id FROM
|
SELECT DISTINCT
|
||||||
|
permissions.user_id,
|
||||||
|
permissions.permission,
|
||||||
|
guacamole_user.user_id
|
||||||
|
FROM
|
||||||
<foreach collection="permissions" item="permission"
|
<foreach collection="permissions" item="permission"
|
||||||
open="(" separator="UNION ALL" close=")">
|
open="(" separator="UNION ALL" close=")">
|
||||||
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
SELECT #{permission.userID,jdbcType=INTEGER} AS user_id,
|
||||||
@@ -119,7 +123,14 @@
|
|||||||
#{permission.objectIdentifier,jdbcType=INTEGER} AS username
|
#{permission.objectIdentifier,jdbcType=INTEGER} AS username
|
||||||
</foreach>
|
</foreach>
|
||||||
AS permissions
|
AS permissions
|
||||||
JOIN guacamole_user ON guacamole_user.username = permissions.username;
|
JOIN guacamole_user ON guacamole_user.username = permissions.username
|
||||||
|
WHERE (permissions.user_id, permissions.permission, guacamole_user.user_id) NOT IN (
|
||||||
|
SELECT
|
||||||
|
guacamole_user_permission.user_id,
|
||||||
|
guacamole_user_permission.permission,
|
||||||
|
guacamole_user_permission.affected_user_id
|
||||||
|
FROM guacamole_user_permission
|
||||||
|
);
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user