Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
87927339
Commit
87927339
authored
Sep 20, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADMIN] update user fun (WIP)
parent
f01a5f59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
User.hs
src/Gargantext/Database/Action/User.hs
+7
-4
User.hs
src/Gargantext/Database/Query/Table/User.hs
+17
-0
No files found.
src/Gargantext/Database/Action/User.hs
View file @
87927339
...
...
@@ -24,7 +24,6 @@ import Gargantext.Prelude.Mail (gargMail, GargMail(..))
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
),
nodeError
,
NodeError
(
..
))
import
Gargantext.Database.Action.Flow
(
getOrMkRoot
)
------------------------------------------------------------------------
mkUser
::
HasNodeError
err
=>
Text
->
NewUser
GargPassword
->
Cmd
err
Int64
mkUser
address
u
=
mkUsers
address
[
u
]
...
...
@@ -36,6 +35,13 @@ mkUsers address us = do
_
<-
mapM
getOrMkRoot
$
map
(
\
u
->
UserName
(
_nu_username
u
))
us
_
<-
liftBase
$
mapM
(
mail
address
)
us
pure
r
------------------------------------------------------------------------
updateUser
::
HasNodeError
err
=>
Text
->
NewUser
GargPassword
->
Cmd
err
Int64
updateUser
address
u
=
do
u'
<-
liftBase
$
toUserHash
u
n
<-
updateUserDB
$
toUserWrite
u'
_
<-
liftBase
$
mail
address
u
pure
n
------------------------------------------------------------------------
-- TODO gargantext.ini config
...
...
@@ -68,9 +74,6 @@ logInstructions address (NewUser u _ (GargPassword p)) =
,
"The Gargantext Team (CNRS)"
]
------------------------------------------------------------------------
------------------------------------------------------------------------
rmUser
::
HasNodeError
err
=>
User
->
Cmd
err
Int64
rmUser
(
UserName
un
)
=
deleteUsers
[
un
]
...
...
src/Gargantext/Database/Query/Table/User.hs
View file @
87927339
...
...
@@ -21,6 +21,7 @@ module Gargantext.Database.Query.Table.User
(
insertUsers
,
toUserWrite
,
deleteUsers
,
updateUserDB
,
queryUserTable
,
getUser
,
insertUsersDemo
...
...
@@ -55,6 +56,22 @@ deleteUsers :: [Username] -> Cmd err Int64
deleteUsers
us
=
mkCmd
$
\
c
->
runDelete
c
userTable
(
\
user
->
in_
(
map
pgStrictText
us
)
(
user_username
user
))
-- Updates email or password only (for now)
updateUserDB
::
UserWrite
->
Cmd
err
Int64
updateUserDB
us
=
mkCmd
$
\
c
->
runUpdate_
c
(
updateUserQuery
us
)
where
updateUserQuery
::
UserWrite
->
Update
Int64
updateUserQuery
us
=
Update
{
uTable
=
userTable
,
uUpdateWith
=
updateEasy
(
\
(
UserDB
_id
_p
ll
su
un
fn
ln
_em
is
ia
dj
)
->
UserDB
_id
p'
ll
su
un
fn
ln
em'
is
ia
dj
)
,
uWhere
=
(
\
row
->
user_username
row
.==
un'
)
,
uReturning
=
rCount
}
where
UserDB
_
p'
_
_
un'
_
_
em'
_
_
_
=
us
-----------------------------------------------------------------------
toUserWrite
::
NewUser
HashPassword
->
UserWrite
toUserWrite
(
NewUser
u
m
(
Auth
.
PasswordHash
p
))
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment