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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
Show 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)
...
@@ -29,7 +29,6 @@ import Gargantext.API.Prelude (GargError)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow
(
FlowCmdM
,
flowCorpusFile
,
flowAnnuaire
,
TermType
(
..
))
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.Hyperdata
(
toHyperdataDocument
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Prelude
(
Cmd
)
...
@@ -42,9 +41,6 @@ main = do
...
@@ -42,9 +41,6 @@ main = do
--{-
--{-
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
let
let
--tt = (Unsupervised EN 6 0 Nothing)
--tt = (Unsupervised EN 6 0 Nothing)
tt
=
(
Multi
EN
)
tt
=
(
Multi
EN
)
...
@@ -70,10 +66,6 @@ main = do
...
@@ -70,10 +66,6 @@ main = do
--}
--}
withDevEnv
iniPath
$
\
env
->
do
withDevEnv
iniPath
$
\
env
->
do
_
<-
if
fun
==
"users"
then
runCmdDev
env
createUsers
else
pure
0
--(cs "false")
_
<-
if
fun
==
"corpus"
_
<-
if
fun
==
"corpus"
then
runCmdDev
env
corpus
then
runCmdDev
env
corpus
else
pure
0
--(cs "false")
else
pure
0
--(cs "false")
...
...
bin/gargantext-init/Main.hs
View file @
f02d3c3d
...
@@ -20,10 +20,10 @@ import Data.Either (Either(..))
...
@@ -20,10 +20,10 @@ import Data.Either (Either(..))
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Node
()
-- instances only
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.Action.Flow
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Query.Table.Node
(
getOrMkList
)
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.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Trigger.Init
(
initFirstTriggers
,
initLastTriggers
)
import
Gargantext.Database.Admin.Trigger.Init
(
initFirstTriggers
,
initLastTriggers
)
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
System.Environment
(
getArgs
)
import
System.Environment
(
getArgs
)
import
Prelude
(
getLine
)
-- TODO put this in gargantext.ini
-- TODO put this in gargantext.ini
secret
::
Text
secret
::
Text
...
@@ -40,12 +41,21 @@ main :: IO ()
...
@@ -40,12 +41,21 @@ main :: IO ()
main
=
do
main
=
do
[
iniPath
]
<-
getArgs
[
iniPath
]
<-
getArgs
putStrLn
"Enter master user (gargantua) _password_ :"
password
<-
getLine
putStrLn
"Enter master user (gargantua) _email_ :"
email
<-
getLine
let
createUsers
::
Cmd
GargError
Int64
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
createUsers
=
insertNewUsers
(
NewUser
"gargantua"
(
cs
email
)
(
GargPassword
$
cs
password
)
:
arbitraryNewUsers
)
let
let
mkRoots
::
Cmd
GargError
[(
UserId
,
RootId
)]
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
-- TODO create all users roots
let
let
...
...
src/Gargantext/Core/Types/Individu.hs
View file @
f02d3c3d
...
@@ -52,7 +52,7 @@ data NewUser a = NewUser { _nu_username :: Username
...
@@ -52,7 +52,7 @@ data NewUser a = NewUser { _nu_username :: Username
deriving
(
Show
)
deriving
(
Show
)
arbitraryUsername
::
[
Username
]
arbitraryUsername
::
[
Username
]
arbitraryUsername
=
[
"gargantua"
]
<>
users
arbitraryUsername
=
{- ["gargantua"] <> -}
users
where
where
users
=
zipWith
(
\
a
b
->
a
<>
(
pack
.
show
)
b
)
users
=
zipWith
(
\
a
b
->
a
<>
(
pack
.
show
)
b
)
(
repeat
"user"
)
([
1
..
20
]
::
[
Int
])
(
repeat
"user"
)
([
1
..
20
]
::
[
Int
])
...
@@ -68,12 +68,13 @@ toUserHash (NewUser u m (GargPassword p)) = do
...
@@ -68,12 +68,13 @@ toUserHash (NewUser u m (GargPassword p)) = do
h
<-
Auth
.
createPasswordHash
p
h
<-
Auth
.
createPasswordHash
p
pure
$
NewUser
u
m
h
pure
$
NewUser
u
m
h
-- TODO remove
arbitraryUsersHash
::
MonadIO
m
arbitraryUsersHash
::
MonadIO
m
=>
m
[
NewUser
HashPassword
]
=>
m
[
NewUser
HashPassword
]
arbitraryUsersHash
=
mapM
toUserHash
arbitraryUsers
arbitraryUsersHash
=
mapM
toUserHash
arbitrary
New
Users
arbitraryUsers
::
[
NewUser
GargPassword
]
arbitrary
New
Users
::
[
NewUser
GargPassword
]
arbitraryUsers
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitrary
New
Users
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitraryUsername
arbitraryUsername
src/Gargantext/Database/Query/Table/User.hs
View file @
f02d3c3d
...
@@ -24,7 +24,7 @@ module Gargantext.Database.Query.Table.User
...
@@ -24,7 +24,7 @@ module Gargantext.Database.Query.Table.User
,
updateUserDB
,
updateUserDB
,
queryUserTable
,
queryUserTable
,
getUser
,
getUser
,
insert
UsersDemo
,
insert
NewUsers
,
selectUsersLightWith
,
selectUsersLightWith
,
userWithUsername
,
userWithUsername
,
userWithId
,
userWithId
...
@@ -141,9 +141,9 @@ getUser u = userLightWithUsername u <$> usersLight
...
@@ -141,9 +141,9 @@ getUser u = userLightWithUsername u <$> usersLight
----------------------------------------------------------------------
----------------------------------------------------------------------
insert
UsersDemo
::
Cmd
err
Int64
insert
NewUsers
::
[
NewUser
GargPassword
]
->
Cmd
err
Int64
insert
UsersDemo
=
do
insert
NewUsers
newUsers
=
do
users
<-
liftBase
arbitraryUsersHash
users
<-
liftBase
$
mapM
toUserHash
newUsers
insertUsers
$
map
toUserWrite
users
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