Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
gargantext
haskell-gargantext
Commits
f02d3c3d
Commit
f02d3c3d
authored
Dec 02, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] init script to create new users
parent
f882428c
Pipeline
#1263
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
21 deletions
+24
-21
Main.hs
bin/gargantext-import/Main.hs
+0
-8
Main.hs
bin/gargantext-init/Main.hs
+14
-4
Individu.hs
src/Gargantext/Core/Types/Individu.hs
+5
-4
User.hs
src/Gargantext/Database/Query/Table/User.hs
+5
-5
No files found.
bin/gargantext-import/Main.hs
View file @
f02d3c3d
...
...
@@ -29,7 +29,6 @@ import Gargantext.API.Prelude (GargError)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow
(
FlowCmdM
,
flowCorpusFile
,
flowAnnuaire
,
TermType
(
..
))
import
Gargantext.Database.Query.Table.User
(
insertUsersDemo
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
toHyperdataDocument
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Prelude
(
Cmd
)
...
...
@@ -42,9 +41,6 @@ main = do
--{-
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
let
--tt = (Unsupervised EN 6 0 Nothing)
tt
=
(
Multi
EN
)
...
...
@@ -70,10 +66,6 @@ main = do
--}
withDevEnv
iniPath
$
\
env
->
do
_
<-
if
fun
==
"users"
then
runCmdDev
env
createUsers
else
pure
0
--(cs "false")
_
<-
if
fun
==
"corpus"
then
runCmdDev
env
corpus
else
pure
0
--(cs "false")
...
...
bin/gargantext-init/Main.hs
View file @
f02d3c3d
...
...
@@ -20,10 +20,10 @@ import Data.Either (Either(..))
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
)
,
arbitraryNewUsers
,
NewUser
(
..
),
arbitraryUsername
,
GargPassword
(
..
)
)
import
Gargantext.Database.Action.Flow
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Query.Table.Node
(
getOrMkList
)
import
Gargantext.Database.Query.Table.User
(
insert
UsersDemo
)
import
Gargantext.Database.Query.Table.User
(
insert
NewUsers
,
)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Trigger.Init
(
initFirstTriggers
,
initLastTriggers
)
...
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Prelude
import
System.Environment
(
getArgs
)
import
Prelude
(
getLine
)
-- TODO put this in gargantext.ini
secret
::
Text
...
...
@@ -40,12 +41,21 @@ main :: IO ()
main
=
do
[
iniPath
]
<-
getArgs
putStrLn
"Enter master user (gargantua) _password_ :"
password
<-
getLine
putStrLn
"Enter master user (gargantua) _email_ :"
email
<-
getLine
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
createUsers
=
insertNewUsers
(
NewUser
"gargantua"
(
cs
email
)
(
GargPassword
$
cs
password
)
:
arbitraryNewUsers
)
let
mkRoots
::
Cmd
GargError
[(
UserId
,
RootId
)]
mkRoots
=
mapM
getOrMkRoot
$
map
UserName
[
"gargantua"
,
"user1"
,
"user2"
,
"user3"
]
mkRoots
=
mapM
getOrMkRoot
$
map
UserName
(
"gargantua"
:
arbitraryUsername
)
-- TODO create all users roots
let
...
...
src/Gargantext/Core/Types/Individu.hs
View file @
f02d3c3d
...
...
@@ -52,7 +52,7 @@ data NewUser a = NewUser { _nu_username :: Username
deriving
(
Show
)
arbitraryUsername
::
[
Username
]
arbitraryUsername
=
[
"gargantua"
]
<>
users
arbitraryUsername
=
{- ["gargantua"] <> -}
users
where
users
=
zipWith
(
\
a
b
->
a
<>
(
pack
.
show
)
b
)
(
repeat
"user"
)
([
1
..
20
]
::
[
Int
])
...
...
@@ -68,12 +68,13 @@ toUserHash (NewUser u m (GargPassword p)) = do
h
<-
Auth
.
createPasswordHash
p
pure
$
NewUser
u
m
h
-- TODO remove
arbitraryUsersHash
::
MonadIO
m
=>
m
[
NewUser
HashPassword
]
arbitraryUsersHash
=
mapM
toUserHash
arbitraryUsers
arbitraryUsersHash
=
mapM
toUserHash
arbitrary
New
Users
arbitraryUsers
::
[
NewUser
GargPassword
]
arbitraryUsers
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitrary
New
Users
::
[
NewUser
GargPassword
]
arbitrary
New
Users
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitraryUsername
src/Gargantext/Database/Query/Table/User.hs
View file @
f02d3c3d
...
...
@@ -24,7 +24,7 @@ module Gargantext.Database.Query.Table.User
,
updateUserDB
,
queryUserTable
,
getUser
,
insert
UsersDemo
,
insert
NewUsers
,
selectUsersLightWith
,
userWithUsername
,
userWithId
...
...
@@ -81,7 +81,7 @@ toUserWrite (NewUser u m (Auth.PasswordHash p)) =
(
pgStrictText
"first_name"
)
(
pgStrictText
"last_name"
)
(
pgStrictText
m
)
(
pgBool
True
)
(
pgBool
True
)
(
pgBool
True
)
Nothing
------------------------------------------------------------------
...
...
@@ -141,9 +141,9 @@ getUser u = userLightWithUsername u <$> usersLight
----------------------------------------------------------------------
insert
UsersDemo
::
Cmd
err
Int64
insert
UsersDemo
=
do
users
<-
liftBase
arbitraryUsersHash
insert
NewUsers
::
[
NewUser
GargPassword
]
->
Cmd
err
Int64
insert
NewUsers
newUsers
=
do
users
<-
liftBase
$
mapM
toUserHash
newUsers
insertUsers
$
map
toUserWrite
users
----------------------------------------------------------------------
...
...
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