# Bug OP-11293 - Tokens not cleaned up on user deletion

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-11293

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 12.3.1 |
| Observed in versions |  |
| Sprint | 12.3.1 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Login as admin
2.  Create a backup token
3.  Create new user
4.  Activate user manually by setting a password as admin
5.  Login as said user in new tab
6.  Create an API token and a backup token
7.  Now the user has 3 tokens: invitation, API, backup
    1.  (maybe the invitation token should be cleaned up upon manual activation?)
8.  Delete the user
9.  Go to backup screen

### What is the buggy behavior?

The page doesn't work due to an internal server error.

(All users with backup tokens are listed which fails since there now is a backup token without an associated user.)

Only the API token gets cleaned up for some reason. The backup and invitation tokens (and possibly others) remain.

### What is the expected behavior?

The page does work normally.

(All tokens get deleted.)

### OpenProject Version

12.3.0
