From 7bebd20bb3c7e16e4bed863a9569295081bde1af Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 1 Nov 2022 15:22:03 +0100 Subject: [PATCH 1/3] fix: users can be edited again (#1515) --- src/app/core/user/user.spec.ts | 7 +++++++ src/app/core/user/user.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/core/user/user.spec.ts b/src/app/core/user/user.spec.ts index b3af54acee..d08b719c91 100644 --- a/src/app/core/user/user.spec.ts +++ b/src/app/core/user/user.spec.ts @@ -36,4 +36,11 @@ describe("User", () => { expect(user.getId()).toBe("test-name"); expect(() => (user.name = "another-name")).toThrowError(); }); + + it("should not fail when name is actually the same", () => { + const user = new User(); + user.name = "test-name"; + + expect(() => (user.name = "test-name")).not.toThrowError(); + }); }); diff --git a/src/app/core/user/user.ts b/src/app/core/user/user.ts index 5f28721864..8ed1077463 100644 --- a/src/app/core/user/user.ts +++ b/src/app/core/user/user.ts @@ -35,7 +35,7 @@ export class User extends Entity { validators: { required: true }, }) set name(value: string) { - if (this._name) { + if (this._name && value !== this._name) { // Throwing error if trying to change existing username const label = User.schema.get("name").label; throw new Error( From 4366ff99fb4abb097556c318436df063a24fd7a5 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 1 Nov 2022 17:05:04 +0100 Subject: [PATCH 2/3] doc: describe how user roles can be created and assigned (#1516) Co-authored-by: Sebastian --- doc/compodoc_sources/concepts/permissions.md | 104 ++++++++++++++----- 1 file changed, 79 insertions(+), 25 deletions(-) diff --git a/doc/compodoc_sources/concepts/permissions.md b/doc/compodoc_sources/concepts/permissions.md index f61c151f8b..1164994d4e 100644 --- a/doc/compodoc_sources/concepts/permissions.md +++ b/doc/compodoc_sources/concepts/permissions.md @@ -1,10 +1,43 @@ -# Permissions +# User Roles and Permissions + +## User Roles + +User roles are used to restrict what components a user can see and what data a user can access and edit. +These roles are stored in the backend and are available in the frontend after a successful login. +At the moment there are two places, depending on your system setup, where the roles can be defined. + +### CouchDB + +When using CouchDB as authenticator, then the roles are directly stored on the `org.couchdb.user` document of a user. +A new role can be added to a user by simply adding the name of the role to the user document. +After the next login, the role will be available in the frontend. + +### Keycloak + +When using Keycloak as an authenticator, the roles are assigned through so called Role-Mappings. +To assign a new role to a user, this role first has to be created in the realm. +To do this go to the Keycloak admin console, select the realm for which you want to create a role and go to the *Realm +roles* menu item. +Here a new role can be created and also a description can be provided for it. +This description should explain non-technical users, what this role is there for. +Default roles that are always available are `user_app`, `admin_app` and `account_manager`. +After a role has been created, the role can be assigned to a user. +This can either be done in the frontend using the `UserSecurityComponent` or via the Keycloak admin console under * +Users* +-> *\