2 Module : Gargantext.Database.Action.User
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
11 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
14 module Gargantext.Database.Action.User
17 -- import Data.Maybe (catMaybes)
18 import Gargantext.Database.Query.Table.User
19 import Gargantext.Core.Types.Individu
20 import Gargantext.Database.Prelude
21 import Gargantext.Prelude
22 import Gargantext.Prelude.Mail (gargMail)
23 import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..), nodeError, NodeError(..))
24 import Gargantext.Database.Action.Flow (getOrMkRoot)
27 ------------------------------------------------------------------------
28 mkUser :: HasNodeError err => NewUser GargPassword -> Cmd err Int64
29 mkUser u = mkUsers [u]
31 mkUsers :: HasNodeError err => [NewUser GargPassword] -> Cmd err Int64
33 us' <- liftBase $ mapM toUserHash us
34 r <- insertUsers $ map toUserWrite us'
35 _ <- mapM getOrMkRoot $ map (\u -> UserName (_nu_username u)) us
36 _ <- liftBase gargMail
39 ------------------------------------------------------------------------
40 rmUser :: HasNodeError err => User -> Cmd err Int64
41 rmUser (UserName un) = deleteUsers [un]
42 rmUser _ = nodeError NotImplYet
45 rmUsers :: HasNodeError err => [User] -> Cmd err Int64