Skip to content

feat(user): add EformUser.IsActive so a login can be disabled (#971) - #972

Merged
renemadsen merged 1 commit into
masterfrom
feat/971-user-is-active
Sep 17, 2026
Merged

renemadsen merged 1 commit into
masterfrom
feat/971-user-is-active

Conversation

@renemadsen

Copy link
Copy Markdown
Member

Closes #971. Step 1 of 4 — design: microting/eform-angular-frontend#8072, spec: microting/eform-angular-frontend#8073.

One property on EformUser:

public bool IsActive { get; set; } = true;

Why

There is no account-state flag today. LockoutEnabled/LockoutEnd exist but are purely the automatic brute-force delay — nothing in the platform sets them administratively — so a known-good credential cannot be refused for policy reasons. Measured on one production tenant: all four resigned workers still hold a working login, one of them seven weeks after resigning.

The = true is load-bearing

The mapping (step 2) declares HasDefaultValue(true), which makes true this property's sentinel; EF Core omits a sentinel-valued column from the INSERT so the store default applies. Without the initializer a freshly constructed EformUser holds false, EF Core writes that explicitly, and every new account would be created disabled.

Verified empirically against EF Core 10.0.12 (the version pinned in this repo) rather than from memory — an earlier draft of the comment had the direction backwards.

This trap is already sprung elsewhere: ExternalLoginEnabled is a shadow bool with HasDefaultValue(true), and a shadow property cannot have an initializer — so every user created since 20250904105541_AddOAuthLoginSupport has it set to 0 despite the declared default. Dormant only because the property is dead code.

No tests in this PR

Nothing reads the flag yet, so there is no behaviour to assert; this repo has no test project either. The test obligation lands with the login-refusal change that consumes it.

For whoever picks up step 2

  • Microting.EformAngularFrontendBase.csproj:14 still pins BasePn 10.0.30 — bump it to this release or dotnet ef migrations add will not see IsActive and will scaffold nothing.
  • Copy the precedent at 20250904105541_AddOAuthLoginSupport.cs:41-46: AddColumn<bool>(name: "IsActive", table: "Users", type: "tinyint(1)", nullable: false, defaultValue: true). A naively scaffolded defaultValue: false would disable every existing account on migrate.
  • The release that picks this package up must also carry that migration: IdentityDbContext maps the property by convention, and the host materialises whole EformUser rows during boot (Startup.cs:502, Program.cs:263), so a package bump without the column stops the host from starting.

🤖 Generated with Claude Code

There is no account-state flag on EformUser today. Lockout exists but is only
ever the automatic brute-force delay -- nothing sets it administratively -- so a
known-good credential cannot be refused for policy reasons. That is what "this
person resigned" needs: on one production tenant all four resigned workers still
hold a working login, one of them seven weeks on.

The "= true" initializer is load-bearing and is documented as such. The mapping
(next step, in eform-angular-frontend-base) declares HasDefaultValue(true), which
makes true this property's sentinel; EF Core omits a sentinel-valued column from
the INSERT so the store default applies. Without the initializer a new EformUser
holds false, EF Core writes it explicitly, and every account would be created
disabled. Verified against EF Core 10.0.12, the version pinned here.

Nothing reads the flag yet, so there is no behaviour to test in this commit; the
test obligation lands with the login-refusal change that reads it.

Part of microting/eform-angular-frontend#8072.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 17, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documentation claims inactive users cannot sign in, but this package does not enforce that behavior yet.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds EformUser.IsActive with an enabled-by-default initializer for future login disabling.

Changes:

  • Adds the account activity flag and explanatory documentation.
  • Preserves enabled defaults for newly created users.
File summaries
File Description
eFormApi.BasePn/Infrastructure/Database/Entities/EformUser.cs Adds IsActive to EformUser.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +40 to +43
/// <summary>
/// False blocks sign-in for this account, a resigned employee say. Not the same as
/// Identity's lockout, which is the automatic brute-force delay.
/// </summary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add EformUser.IsActive so a login can be disabled

2 participants