Skip to content

add disabled option to user#1351

Merged
joshunrau merged 2 commits into
DouglasNeuroInformatics:mainfrom
joshunrau:disable-user
May 5, 2026
Merged

add disabled option to user#1351
joshunrau merged 2 commits into
DouglasNeuroInformatics:mainfrom
joshunrau:disable-user

Conversation

@joshunrau
Copy link
Copy Markdown
Collaborator

@joshunrau joshunrau commented May 5, 2026

Summary by CodeRabbit

  • New Features
    • Introduced the ability to disable user accounts independently. When a user is marked as disabled, they are prevented from logging in to the system. Administrators can easily toggle the disabled status for any user through the admin interface. This feature provides centralized access control management without requiring permanent account deletion.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9e120216-dd9e-4268-ab84-2867e242fd79

📥 Commits

Reviewing files that changed from the base of the PR and between c48ab4d and 3e9853d.

📒 Files selected for processing (7)
  • apps/api/prisma/schema.prisma
  • apps/api/src/auth/auth.service.ts
  • apps/api/src/users/dto/create-user.dto.ts
  • apps/api/src/users/users.service.ts
  • apps/web/src/routes/_app/admin/users/create.tsx
  • apps/web/src/routes/_app/admin/users/index.tsx
  • packages/schemas/src/user/user.ts

Walkthrough

This PR adds a disabled boolean field to the User model and implements account disablement logic. The field is added to the Prisma schema, propagated through DTOs and validation schemas, integrated into the login flow to reject disabled accounts, and exposed in user creation/management UI forms.

Changes

Account Disablement Feature

Layer / File(s) Summary
Data Shape
apps/api/prisma/schema.prisma, packages/schemas/src/user/user.ts, apps/api/src/users/dto/create-user.dto.ts
Prisma User model adds optional disabled field; Zod schemas updated with disabled: z.boolean().nullish() for $User and disabled: z.boolean().optional() for $CreateUserData; CreateUserDto adds disabled?: boolean property.
Login Validation
apps/api/src/auth/auth.service.ts
AuthService.login() now checks user.disabled and throws ForbiddenException('Account Disabled') before password verification if the account is disabled.
User Creation & Persistence
apps/api/src/users/users.service.ts
UsersService.create() destructures disabled from CreateUserDto and includes it in the user record creation payload.
Frontend Forms & UI
apps/web/src/routes/_app/admin/users/create.tsx, apps/web/src/routes/_app/admin/users/index.tsx
User create and update forms add disabled radio boolean fields under permissions/authorization sections with translated labels; both forms initialize disabled to false by default.

Sequence Diagram

sequenceDiagram
    participant Client
    participant AuthService
    participant UserService
    participant Database

    Client->>AuthService: login(email, password)
    AuthService->>UserService: findByEmail(email)
    UserService->>Database: query User
    Database-->>UserService: User { disabled: true/false, ... }
    UserService-->>AuthService: user
    
    alt user.disabled == true
        AuthService-->>Client: ForbiddenException('Account Disabled')
    else user.disabled == false
        AuthService->>AuthService: comparePassword(password)
        AuthService->>AuthService: generateToken()
        AuthService-->>Client: { accessToken, ... }
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@joshunrau joshunrau merged commit bc0b156 into DouglasNeuroInformatics:main May 5, 2026
1 of 2 checks passed
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.

1 participant