Users, Roles and Groups (USR)

The usr submodule of sys owns the people who can sign in and the groupings that drive authorization: users, user types, roles, and user groups, plus the link tables that bind them. It seeds a default admin user, group, and role at bootstrap, exposes the logged-in and batch-job users to the rest of the system, and provides the dynamic UI for ticking groups and roles per user. It depends on sys.loc for the locale and time-zone defaults attached to a new user, and on sys.acl only as a downstream consumer of roles.

Concepts

User

A person (or technical agent) who can authenticate and act in the system. Each user has a code that doubles as the Spring Security username, a password, locale and time-zone, plus UI preferences.

User Type

A classification of users that carries the default page shown after sign-in.

Role

A named permission grouping. The acl submodule grants object-level access to roles; this submodule defines the role identities themselves.

User Group

A named group of users. A user inherits every role attached to every group it is a member of.

User Role

Direct assignment of a role to an individual user — used when role membership should not flow through a group.

User Group Role

A role attached to a group; every member of the group inherits the role.

User Group Member

A user’s membership in a group.

Logged-in User

The user resolved from the current Spring Security context. Used by every action that needs to know "who is doing this".

Batch Job User

The technical user the system signs in as when running background jobs that have no human session. Its credentials are read from properties.

Entities

USR entities

User Type (UserType)

A classification of users.

FieldDescription

code

Business key (up to 8 characters).

description

Human-readable name.

defaultPage

Optional default page (an ApplicationPath) the user lands on after sign-in.

User (User)

A user account.

FieldDescription

code

Business key — also the Spring Security username.

userType

The user’s classification.

_password

Optional encrypted password. Stored encoded by the framework’s PasswordEncoder; never read back as clear text.

accountLocked

Whether sign-in is blocked.

name

Display name.

_email

Optional email address.

sLocale

Locale used to format dates/numbers/text for this user.

sTimeZone

Time zone used to display timestamps for this user.

desktopDarkTheme

Preference flag: dark vs. light desktop theme. Default false.

desktopMenuBar

Preference flag: show or hide the desktop menu bar. Default false.

Role (Role)

A named permission grouping. Used by the acl submodule to grant object access; this submodule only stores the role identities.

FieldDescription

code

Business key (a RoleCode).

description

Human-readable name.

User Group (UserGroup)

A group whose members all share its assigned roles.

FieldDescription

name

Business key (a UserGroupName).

description

Human-readable description.

User Role (UserRole)

Direct role assignment to an individual user.

FieldDescription

user

Owning user (composite business key with role).

role

The role assigned.

User Group Role (UserGroupRole)

Role attached to a group. Every member of the group inherits the role.

FieldDescription

userGroup

Owning group (composite business key with role).

role

The role attached to the group.

User Group Member (UserGroupMember)

User membership in a group.

FieldDescription

userGroup

Owning group (composite business key with user).

user

The member user.

Functionality

Bootstrap of default user, group, and role

SYS_USR_BootstrapApi.bootstrap runs at system bootstrap and idempotently provisions a baseline set of records when they are missing: a default UserType (001), a default User (admin), a default UserGroup (001), a default Role (sys_ope), and the UserGroupMember and UserGroupRole rows that bind the admin user to the group and the role to the group. Existing records are never overwritten. The bootstrap pulls the default locale and time zone from sys.loc and fails fast if those are missing.

The defaults that govern this step are constants on SYS_USR_Constant:

ConstantValue

DEFAULT_USER_TYPE

001

DEFAULT_USER_TYPE_PAGE

sAclEntryPage

DEFAULT_USER_CODE

admin

DEFAULT_USER_PASSWORD

admin

DEFAULT_USER_GROUP

001

DEFAULT_ROLE

sys_ope

Logged-in user resolution

UserReaderService.getLoggedInUser reads the current username from the Spring Security context (VenloContext.getUserDetails()) and looks up the matching User row. It raises a business exception when the username does not resolve to a user — used by every action that needs to attribute work to "the current user" (audit fields, theme preferences, etc.).

Batch-job user sign-in

BatchUserReaderService provides the technical user the system runs as for background jobs that have no interactive session. loginBatchJobUser registers the configured batch-job credentials with VenloContext.setBackgroundUserDetails; getBatchJobUser returns the corresponding User entity. Credentials come from SystemSettingService, which reads the erp.sys.usr.batchJobUserName and erp.sys.usr.batchJobPassword properties and trims them.

UI preference toggles

UserPreferenceViewModel exposes two actions that flip the dark-theme preference on the currently logged-in user. Both actions are always enabled and persist immediately — the user does not need to save the preference page.

ActionEffect

setDesktopDarkTheme

Sets desktopDarkTheme = true on the logged-in user.

setDesktopLightTheme

Sets desktopDarkTheme = false on the logged-in user.

Dynamic group-role and group-member matrices

Two view models render a dynamic checkbox matrix so administrators can manage role and group bindings without scrolling through long lists of link rows:

UserGroupViewModel_Roles

Builds one boolean field per Role on the user-group edit page. Loading a user group ticks the boxes that match its UserGroupRole rows; saving the record removes every existing role binding for the group and re-creates them from the ticked boxes.

UserViewModel_GroupMembers

Builds one boolean field per UserGroup on the user edit page. Loading a user ticks the boxes that match its UserGroupMember rows; saving rewrites the user’s group memberships from the ticked boxes. Password edits go through Spring Security’s PasswordEncoder before being persisted.

Public API

SYS_USR_QueryApi

Read-side facade.

MethodDescription

loginBatchJobUser()

Signs the runtime in as the batch-job technical user.

getBatchJobUser(HasTrace)

Returns the batch-job technical user.

getLoggedInUser(HasTrace)

Returns the user matching the current Spring Security session.

findUserById(UUID)

User by primary id.

findUserByCode(UserCode)

User by code, or null.

findRoleByCode(RoleCode)

Role by code, or null.

findAllRolesByUser(User)

Direct role assignments for a user.

findAllGroupMembersByUserGroup(UserGroup)

Members of a group.

findAllGroupMembersByUser(User)

Group memberships of a user.

findAllRolesByUserGroup(UserGroup)

Roles attached to a group.

SYS_USR_CommandApi

Currently an empty placeholder — no cross-module write operations are exposed. User and group records are maintained through their default UI pages and the dynamic matrix view models.

SYS_USR_BootstrapApi

Single entry point bootstrap(HasTrace) — see Bootstrap of default user, group, and role above. Called by the system-wide bootstrap sequence, not by end users.

ViewModel actions

ActionUser-visible effect

setDesktopDarkTheme (on User Preferences)

Switches the desktop UI to the dark theme for the current user.

setDesktopLightTheme (on User Preferences)

Switches the desktop UI to the light theme for the current user.