mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Fix deleting users
Can now be deleted by id or login. It was wrongly documented.
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
package docspell.restserver.routes
|
||||
|
||||
import cats.data.OptionT
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
|
||||
@ -73,8 +74,13 @@ object UserRoutes {
|
||||
for {
|
||||
users <- backend.collective.listUser(user.account.collectiveId)
|
||||
ar <-
|
||||
if (users.exists(_.uid == id)) backend.collective.deleteUser(id)
|
||||
else UpdateResult.notFound.pure[F]
|
||||
OptionT
|
||||
.fromOption[F](
|
||||
users
|
||||
.find(u => u.uid == id || u.login == id)
|
||||
)
|
||||
.semiflatMap(u => backend.collective.deleteUser(u.uid))
|
||||
.getOrElse(UpdateResult.notFound)
|
||||
resp <- Ok(basicResult(ar, "User deleted."))
|
||||
} yield resp
|
||||
|
||||
|
Reference in New Issue
Block a user