Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove isViewer flag #1415

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- It is now possible to restart a workflow from every publication status.
- Renamed codelist entries for casing type and casing material.
- Upgraded to PostgreSQL 15 and PostGIS 3.4.
- Removed unused `IsViewer` flag from user.

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions config/create-user.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
INSERT INTO bdms.users
(created_usr, admin_usr, viewer_usr, username, settings_usr, firstname, lastname)
(created_usr, admin_usr, username, settings_usr, firstname, lastname)
VALUES
(
NOW(), true, true, 'GeoWerkstatt',
NOW(), true, 'GeoWerkstatt',
'{"filter": {"custom": {"borehole_identifier": true, "project_name": true, "landuse": true, "alternate_name": true, "canton": true, "city": true}, "restriction": true, "restriction_until": true, "extended": {"original_name": true, "method": true, "status": true}, "kind": true, "elevation_z": true, "length": true, "drilling_date": true, "zoom2selected": true}, "boreholetable": {"orderby": "original_name", "direction": "ASC"}, "eboreholetable": {"orderby": "creation", "direction": "DESC"}, "map": {"explorer": {}, "editor": {}}, "appearance": {"explorer": 1}}',
'GeoWerkstatt', 'user');
4 changes: 1 addition & 3 deletions src/api-legacy/v1/basehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ async def prepare(self):
ELSE
TRUE
END AS terms,
COALESCE(
viewer_usr, FALSE
) as viewer,
TRUE as viewer,
COALESCE(
admin_usr, FALSE
) as admin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
{
claimsIdentity.AddClaim(new Claim(ClaimTypes.Role, PolicyNames.Admin));
}
else if (authenticatedUser.IsViewer)
else
{
claimsIdentity.AddClaim(new Claim(ClaimTypes.Role, PolicyNames.Viewer));
}
Expand All @@ -52,7 +52,7 @@ public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
if (subjectId is null)
return null;

var user = dbContext.Users.SingleOrDefault(u => u.SubjectId == subjectId) ?? new User { SubjectId = subjectId, IsViewer = true };
var user = dbContext.Users.SingleOrDefault(u => u.SubjectId == subjectId) ?? new User { SubjectId = subjectId };
user.FirstName = principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value ?? user.FirstName;
user.LastName = principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname)?.Value ?? user.LastName;
user.Name = $"{user.FirstName[0]}. {user.LastName}";
Expand Down
2 changes: 1 addition & 1 deletion src/api/Authentication/PolicyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class PolicyNames
public const string Admin = "Admin";

/// <summary>
/// Users with <see cref="User.IsViewer"/> set to <c>true</c>.
/// Users with <see cref="User.IsAdmin"/> set to <c>false</c>.
/// </summary>
public const string Viewer = "Viewer";
}
Loading
Loading