# ReactivateUser

## Permission Scope

user

## Overview

ReactivateUser transitions a user from INACTIVE status back to ACTIVE status, restoring their access to the system. This command is used when a previously offboarded user returns, such as a contractor returning for a new engagement or a reinstated employee.

Only users in INACTIVE status can be reactivated. Historical associations and role assignments are preserved and become active again.

## Business Rules

- User must exist in the system
- User must be in INACTIVE status
- Transitions user status from INACTIVE to ACTIVE
- Preserves historical role assignments and associations
- Recomputes permissions from the preserved role assignments, restoring effective access
- Generates USER_REACTIVATED audit event with actor ID, timestamp, and previous status

## Process Flow

```mermaid
flowchart TD
    A[Receive reactivate request] --> B{User exists?}
    B -->|No| C[Return error: USER_NOT_FOUND]
    B -->|Yes| D{Status is INACTIVE?}
    D -->|No| E[Return error: INVALID_STATUS_TRANSITION]
    D -->|Yes| F[Update status to ACTIVE]
    F --> G[Log USER_REACTIVATED audit event]
    G --> H[Return updated user]
```

## External Dependencies

- None

## Error Scenarios

- **USER_NOT_FOUND**: Specified user ID does not exist
- **INVALID_STATUS_TRANSITION**: Requested status transition is not allowed from the current status

## Test Cases

- throws when user does not exist
- throws when user is PENDING
- throws when user is already ACTIVE
- reactivates INACTIVE user to ACTIVE
