Commit 0df3ec78 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] if username or password have space in it

parent 7cb79ded
#!/bin/bash
# To get infos
# nix-shell -p nix-info --run "nix-info -m"
nix-channel --update
nix-env -iA nixpkgs.nix nixpkgs.cacert
nix-shell --show-trace --option build-fallback true --run build
......@@ -12,6 +12,7 @@ import Reactix.SyntheticEvent as E
import Reactix.DOM.HTML as H
import Toestand as T
import Toestand (useFocusedFields)
import Data.String as String
import Gargantext.Components.Forms (clearfix, formGroup)
import Gargantext.Components.Login.Types (AuthRequest(..), FormType(..))
......@@ -85,13 +86,12 @@ formLoginLink backend =
type SubmitButtonProps s v = ( cell :: T.Box Form | Props s v )
submitButton
:: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
=> R2.Leaf (SubmitButtonProps s v)
submitButton :: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
=> R2.Leaf (SubmitButtonProps s v)
submitButton = R2.leafComponent submitButtonCpt
submitButtonCpt
:: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
=> R.Component (SubmitButtonProps s v)
submitButtonCpt :: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
=> R.Component (SubmitButtonProps s v)
submitButtonCpt = here.component "submitButton" cpt where
cpt { backend, formType, sessions, visible, cell } _ = do
{ agreed, username, password } <- T.useLive T.unequal cell
......@@ -115,7 +115,14 @@ submitForm { backend, sessions, visible } cell e = do
*> T.write false visible
*> T.write (state { error = "" }) cell
where
req { username, password } = AuthRequest { username, password }
-- User usually copy space before or after the username and password
req { username, password } = AuthRequest {username:cleanString username, password:cleanString password }
-- req { username, password } = AuthRequest {username, password }
cleanString :: String -> String
cleanString str = String.replace (String.Pattern " ")
(String.Replacement "") str
csrfTokenInput :: R.Element -- TODO hard-coded CSRF token
csrfTokenInput = H.input { type: "hidden", name, value } where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment