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
39b9ed39
Commit
39b9ed39
authored
Sep 14, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] gargPassUser improved
parent
423d457d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
User.hs
src/Gargantext/Prelude/Crypto/Pass/User.hs
+5
-5
No files found.
src/Gargantext/Prelude/Crypto/Pass/User.hs
View file @
39b9ed39
...
...
@@ -17,20 +17,21 @@ module Gargantext.Prelude.Crypto.Pass.User
import
Data.List
((
!!
))
import
Gargantext.Prelude
import
Gargantext.Prelude.Utils
(
shuffle
)
import
System.Random
-- TODO add this as parameter to gargantext.ini
gargPassUser
::
(
Num
a
,
Enum
a
)
=>
a
->
[
b
]
->
IO
[
b
]
gargPassUser
=
gargPassUser'
3333
gargPassUser
::
(
Num
a
,
Enum
a
,
Integral
a
)
=>
a
->
[
b
]
->
IO
[
b
]
gargPassUser
n
=
gargPassUser'
(
100
*
fromIntegral
n
)
n
gargPassUser'
::
(
Num
a
,
Enum
a
)
=>
Int
->
a
->
[
b
]
->
IO
[
b
]
gargPassUser'
threshold
size
wlist
|
length
wlist
>
threshold
=
generatePassword
size
wlist
|
otherwise
=
panic
"List to short"
generatePassword
::
(
Num
a
,
Enum
a
)
=>
a
->
[
b
]
->
IO
[
b
]
generatePassword
size
wlist
=
mapM
(
\
_
->
getRandomElement
wlist
)
[
1
..
size
]
generatePassword
size
wlist
=
shuffle
wlist
>>=
\
wlist'
->
mapM
(
\
_
->
getRandomElement
wlist'
)
[
1
..
size
]
getRandomIndex
::
Foldable
t
=>
t
a
->
IO
Int
getRandomIndex
list
=
randomRIO
(
0
,
(
length
list
-
1
))
...
...
@@ -40,4 +41,3 @@ getRandomElement list = do
index
<-
(
getRandomIndex
list
)
pure
(
list
!!
index
)
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