From e89b571ab2f344f6683a506398c3491a864a8d53 Mon Sep 17 00:00:00 2001 From: eikek Date: Tue, 7 Sep 2021 00:18:02 +0200 Subject: [PATCH] Add a route to show what is deleted --- .../src/main/resources/docspell-openapi.yml | 51 +++++++++++++++++-- modules/webapp/src/main/elm/Api.elm | 11 ++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/modules/restapi/src/main/resources/docspell-openapi.yml b/modules/restapi/src/main/resources/docspell-openapi.yml index b6d5112c..b6a5648c 100644 --- a/modules/restapi/src/main/resources/docspell-openapi.yml +++ b/modules/restapi/src/main/resources/docspell-openapi.yml @@ -1309,9 +1309,9 @@ paths: application/json: schema: $ref: "#/components/schemas/BasicResult" - /sec/user/{id}: + /sec/user/{username}: delete: - operationId: "sec-user-delete-by-id" + operationId: "sec-user-delete-by-username" tags: [ Collective ] summary: Delete a user. description: | @@ -1319,7 +1319,7 @@ paths: security: - authTokenHeader: [] parameters: - - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/username" responses: 200: description: Ok @@ -1327,6 +1327,27 @@ paths: application/json: schema: $ref: "#/components/schemas/BasicResult" + /sec/user/{username}/deleteData: + get: + operationId: "sec-user-delete-data" + tags: [ Collective ] + summary: Shows some data that would be deleted if the user is deleted + description: | + Gets some data that would be deleted, when the user with the + given username is deleted. The `username` must be part of this + collective. + security: + - authTokenHeader: [] + parameters: + - $ref: "#/components/parameters/username" + responses: + 200: + description: Ok + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteUserData" + /sec/user/changePassword: post: operationId: "sec-user-change-password" @@ -4068,6 +4089,23 @@ paths: components: schemas: + DeleteUserData: + description: | + An excerpt of data that would be deleted when deleting the + associated user. + required: + - folders + - sentMails + properties: + folders: + type: array + items: + type: string + format: ident + sentMails: + type: integer + format: int32 + SecondFactor: description: | Provide a second factor for login. @@ -6206,6 +6244,13 @@ components: required: true schema: type: string + username: + name: username + in: path + required: true + description: The username of a user of this collective + schema: + type: string itemId: name: itemId in: path diff --git a/modules/webapp/src/main/elm/Api.elm b/modules/webapp/src/main/elm/Api.elm index e9588df1..325dddf1 100644 --- a/modules/webapp/src/main/elm/Api.elm +++ b/modules/webapp/src/main/elm/Api.elm @@ -43,6 +43,7 @@ module Api exposing , deleteSource , deleteTag , deleteUser + , deleteUserData , disableOtp , fileURL , getAttachmentMeta @@ -162,6 +163,7 @@ import Api.Model.CollectiveSettings exposing (CollectiveSettings) import Api.Model.ContactList exposing (ContactList) import Api.Model.CustomFieldList exposing (CustomFieldList) import Api.Model.CustomFieldValue exposing (CustomFieldValue) +import Api.Model.DeleteUserData exposing (DeleteUserData) import Api.Model.DirectionValue exposing (DirectionValue) import Api.Model.EmailSettings exposing (EmailSettings) import Api.Model.EmailSettingsList exposing (EmailSettingsList) @@ -1467,6 +1469,15 @@ deleteUser flags user receive = } +deleteUserData : Flags -> String -> (Result Http.Error DeleteUserData -> msg) -> Cmd msg +deleteUserData flags username receive = + Http2.authGet + { url = flags.config.baseUrl ++ "/api/v1/sec/user/" ++ username ++ "/deleteData" + , account = getAccount flags + , expect = Http.expectJson receive Api.Model.DeleteUserData.decoder + } + + --- Job Queue