Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-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
4
Merge Requests
4
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
purescript-gargantext
Commits
5a8e5abd
Commit
5a8e5abd
authored
Jul 18, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/405-dev-lost-password-design' into dev
parents
eb1bb88e
a0cef540
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
12 deletions
+89
-12
ForgotPassword.purs
src/Gargantext/Components/ForgotPassword.purs
+36
-0
ForgotPassword.purs
src/Gargantext/Components/Login/ForgotPassword.purs
+23
-5
Router.purs
src/Gargantext/Components/Router.purs
+19
-1
Router.purs
src/Gargantext/Router.purs
+2
-1
Routes.purs
src/Gargantext/Routes.purs
+9
-5
No files found.
src/Gargantext/Components/ForgotPassword.purs
0 → 100644
View file @
5a8e5abd
module Gargantext.Components.ForgotPassword where
import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Gargantext.Config.REST (AffRESTError, logRESTError, get)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
here :: R2.Here
here = R2.here "Gargantext.Components.ForgotPassword"
type ForgotPasswordProps = ( server :: String, uuid :: String )
forgotPasswordLayout :: R2.Component ForgotPasswordProps
forgotPasswordLayout = R.createElement forgotPasswordLayoutCpt
forgotPasswordLayoutCpt :: R.Component ForgotPasswordProps
forgotPasswordLayoutCpt = here.component "forgotPasswordLayout" cpt where
cpt { server, uuid } _ = do
useLoader { errorHandler
, loader: loadPassword
, path: { server, uuid }
, render: \{ password } ->
H.p {} [ H.text ("Your new password is: " <> password) ] }
where
errorHandler = logRESTError here "[forgotPasswordLayout]"
------------------------------------
type PasswordData = ( password :: String )
loadPassword :: Record ForgotPasswordProps -> AffRESTError (Record PasswordData)
loadPassword { server, uuid } = get Nothing (server <> "/api/v1.0/forgot-password?uuid=" <> uuid )
src/Gargantext/Components/Login/ForgotPassword.purs
View file @
5a8e5abd
module Gargantext.Components.Login.ForgotPassword where
module Gargantext.Components.Login.ForgotPassword where
import Gargantext.Prelude
import DOM.Simple.Event as DE
import DOM.Simple.Event as DE
import Data.Either (Either(..))
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Formula as F
import Gargantext.Components.Forms (formGroup)
import Gargantext.Components.Forms (formGroup)
import Gargantext.Ends (Backend)
import Gargantext.Ends (Backend)
import Gargantext.Prelude
import Gargantext.Sessions (Sessions, postForgotPasswordRequest)
import Gargantext.Sessions (Sessions, postForgotPasswordRequest)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Formula as F
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Reactix.SyntheticEvent as E
import Reactix.SyntheticEvent as E
...
@@ -30,13 +32,15 @@ forgotPasswordCpt :: R.Component Props
...
@@ -30,13 +32,15 @@ forgotPasswordCpt :: R.Component Props
forgotPasswordCpt = here.component "forgotPassword" cpt where
forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { backend, sessions } _ = do
cpt { backend, sessions } _ = do
email <- T.useBox ""
email <- T.useBox ""
message <- T.useBox ""
pure $ H.div { className: "row" }
pure $ H.div { className: "row" }
[ H.form { className: "text-center col-md-12" }
[ H.form { className: "text-center col-md-12" }
[ H.h4 {} [ H.text "Forgot password" ]
[ H.h4 {} [ H.text "Forgot password" ]
, messageDisplay { message }
, formGroup
, formGroup
[ emailInput email ]
[ emailInput email ]
, submitButton { backend, email, sessions }
, submitButton { backend, email, sessions
, message
}
]
]
]
]
...
@@ -50,14 +54,15 @@ emailInput value = F.bindInput { value
...
@@ -50,14 +54,15 @@ emailInput value = F.bindInput { value
, maxLength: "254" }
, maxLength: "254" }
type SubmitButtonProps =
type SubmitButtonProps =
( email :: T.Box Email
( email :: T.Box Email
, message :: T.Box String
| Props )
| Props )
submitButton :: R2.Leaf SubmitButtonProps
submitButton :: R2.Leaf SubmitButtonProps
submitButton = R2.leafComponent submitButtonCpt
submitButton = R2.leafComponent submitButtonCpt
submitButtonCpt :: R.Component SubmitButtonProps
submitButtonCpt :: R.Component SubmitButtonProps
submitButtonCpt = here.component "submitButton" cpt where
submitButtonCpt = here.component "submitButton" cpt where
cpt { backend, email, sessions
} _ = do
cpt { backend, email, sessions
, message
} _ = do
email' <- T.useLive T.unequal email
email' <- T.useLive T.unequal email
pure $ H.div {className: "form-group text-center"}
pure $ H.div {className: "form-group text-center"}
...
@@ -75,3 +80,16 @@ submitButtonCpt = here.component "submitButton" cpt where
...
@@ -75,3 +80,16 @@ submitButtonCpt = here.component "submitButton" cpt where
launchAff_ $ do
launchAff_ $ do
res <- postForgotPasswordRequest backend email'
res <- postForgotPasswordRequest backend email'
liftEffect $ here.log2 "res" res
liftEffect $ here.log2 "res" res
liftEffect $ case res of
Left s -> T.write_ s message
Right _ -> T.write_ "Request sent!" message
messageDisplay :: R2.Leaf (message :: T.Box String)
messageDisplay = R2.leafComponent messageDisplayCpt
messageDisplayCpt :: R.Component (message :: T.Box String)
messageDisplayCpt = here.component "messageDisplay" cpt where
cpt {message} _ = do
message' <- T.useLive T.unequal message
pure $ H.p {} [H.text message']
\ No newline at end of file
src/Gargantext/Components/Router.purs
View file @
5a8e5abd
...
@@ -5,7 +5,8 @@ import Gargantext.Prelude
...
@@ -5,7 +5,8 @@ import Gargantext.Prelude
import Data.Array (filter, length)
import Data.Array (filter, length)
import Data.Array as A
import Data.Array as A
import Data.Foldable (intercalate)
import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..))
import Data.Map as M
import Data.Maybe (Maybe(..), fromMaybe)
import Data.UUID (UUID)
import Data.UUID (UUID)
import Data.UUID as UUID
import Data.UUID as UUID
import Effect (Effect)
import Effect (Effect)
...
@@ -13,6 +14,7 @@ import Gargantext.Components.App.Store (Boxes)
...
@@ -13,6 +14,7 @@ import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.ErrorsView (errorsView)
import Gargantext.Components.ErrorsView (errorsView)
import Gargantext.Components.Forest (forestLayout)
import Gargantext.Components.Forest (forestLayout)
import Gargantext.Components.Login (login)
import Gargantext.Components.Login (login)
import Gargantext.Components.ForgotPassword (forgotPasswordLayout)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contact (contactLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contact (contactLayout)
...
@@ -316,6 +318,7 @@ renderRouteCpt = R.memo' $ here.component "renderRoute" cpt where
...
@@ -316,6 +318,7 @@ renderRouteCpt = R.memo' $ here.component "renderRoute" cpt where
GR.Team s n -> team (sessionNodeProps s n) []
GR.Team s n -> team (sessionNodeProps s n) []
GR.NodeTexts s n -> texts (sessionNodeProps s n) []
GR.NodeTexts s n -> texts (sessionNodeProps s n) []
GR.UserPage s n -> user (sessionNodeProps s n) []
GR.UserPage s n -> user (sessionNodeProps s n) []
GR.ForgotPassword p -> forgotPassword {boxes, params: p} []
]
]
--------------------------------------------------------------
--------------------------------------------------------------
...
@@ -690,3 +693,18 @@ contactCpt = here.component "contact" cpt where
...
@@ -690,3 +693,18 @@ contactCpt = here.component "contact" cpt where
} `Record.merge` sessionProps
} `Record.merge` sessionProps
pure $ authed authedProps []
pure $ authed authedProps []
--------------------------------------------------------------
type ForgotPasswordProps = ( params :: (M.Map String String) | Props)
forgotPassword :: R2.Component ForgotPasswordProps
forgotPassword = R.createElement forgotPasswordCpt
forgotPasswordCpt :: R.Component ForgotPasswordProps
forgotPasswordCpt = here.component "forgotPassword" cpt where
cpt { params } _ = do
let server = fromMaybe "" $ M.lookup "server" params
let uuid = fromMaybe "" $ M.lookup "uuid" params
pure $ forgotPasswordLayout { server, uuid } []
src/Gargantext/Router.purs
View file @
5a8e5abd
...
@@ -6,11 +6,12 @@ import Data.Foldable (oneOf)
...
@@ -6,11 +6,12 @@ import Data.Foldable (oneOf)
import Data.Int (floor)
import Data.Int (floor)
import Gargantext.Routes (AppRoute(..))
import Gargantext.Routes (AppRoute(..))
import Gargantext.Types (SessionId(..))
import Gargantext.Types (SessionId(..))
import Routing.Match (Match, lit, num, str)
import Routing.Match (Match, lit, num,
params,
str)
router :: Match AppRoute
router :: Match AppRoute
router = oneOf
router = oneOf
[ Login <$ route "login"
[ Login <$ route "login"
, ForgotPassword <$> (route "forgotPassword" *> params)
, Folder <$> (route "folder" *> sid) <*> int
, Folder <$> (route "folder" *> sid) <*> int
, FolderPrivate <$> (route "folderPrivate" *> sid) <*> int
, FolderPrivate <$> (route "folderPrivate" *> sid) <*> int
, FolderPublic <$> (route "folderPublic" *> sid) <*> int
, FolderPublic <$> (route "folderPublic" *> sid) <*> int
...
...
src/Gargantext/Routes.purs
View file @
5a8e5abd
...
@@ -4,6 +4,7 @@ import Prelude
...
@@ -4,6 +4,7 @@ import Prelude
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.UUID (UUID)
import Data.UUID (UUID)
import Data.Map as M
import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType, Id, Limit, ListId, DocId, NgramsGetOpts, NgramsGetTableAllOpts, NodeType, Offset, OrderBy, SearchOpts, SessionId, TabSubType, TabType, TermList)
import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType, Id, Limit, ListId, DocId, NgramsGetOpts, NgramsGetTableAllOpts, NodeType, Offset, OrderBy, SearchOpts, SessionId, TabSubType, TabType, TermList)
import Gargantext.Types as GT
import Gargantext.Types as GT
...
@@ -32,6 +33,7 @@ data AppRoute
...
@@ -32,6 +33,7 @@ data AppRoute
| Team SessionId Int
| Team SessionId Int
| NodeTexts SessionId Int
| NodeTexts SessionId Int
| UserPage SessionId Int
| UserPage SessionId Int
| ForgotPassword (M.Map String String)
derive instance Eq AppRoute
derive instance Eq AppRoute
...
@@ -63,6 +65,7 @@ data SessionRoute
...
@@ -63,6 +65,7 @@ data SessionRoute
instance Show AppRoute where
instance Show AppRoute where
show Home = "Home"
show Home = "Home"
show Login = "Login"
show Login = "Login"
show (ForgotPassword u) = "ForgotPassword" <> show u
show (Folder s i) = "Folder" <> show i <> " (" <> show s <> ")"
show (Folder s i) = "Folder" <> show i <> " (" <> show s <> ")"
show (FolderPrivate s i) = "FolderPrivate" <> show i <> " (" <> show s <> ")"
show (FolderPrivate s i) = "FolderPrivate" <> show i <> " (" <> show s <> ")"
show (FolderPublic s i) = "FolderPublic" <> show i <> " (" <> show s <> ")"
show (FolderPublic s i) = "FolderPublic" <> show i <> " (" <> show s <> ")"
...
@@ -90,11 +93,12 @@ instance Show AppRoute where
...
@@ -90,11 +93,12 @@ instance Show AppRoute where
appPath :: AppRoute -> String
appPath :: AppRoute -> String
appPath Home = ""
appPath Home = ""
appPath Login = "login"
appPath Login = "login"
appPath (Folder s i) = "folder/" <> show s <> "/" <> show i
appPath (ForgotPassword u) = "forgotPassword/" <> show u
appPath (FolderPrivate s i) = "folderPrivate/" <> show s <> "/" <> show i
appPath (Folder s i) = "folder/" <> show s <> "/" <> show i
appPath (FolderPublic s i) = "folderPublic/" <> show s <> "/" <> show i
appPath (FolderPrivate s i) = "folderPrivate/" <> show s <> "/" <> show i
appPath (FolderShared s i) = "folderShared/" <> show s <> "/" <> show i
appPath (FolderPublic s i) = "folderPublic/" <> show s <> "/" <> show i
appPath (Team s i) = "team/" <> show s <> "/" <> show i
appPath (FolderShared s i) = "folderShared/" <> show s <> "/" <> show i
appPath (Team s i) = "team/" <> show s <> "/" <> show i
appPath (CorpusDocument s c l i) = "corpus/" <> show s <> "/" <> show c <> "/list/" <> show l <> "/document/" <> show i
appPath (CorpusDocument s c l i) = "corpus/" <> show s <> "/" <> show c <> "/list/" <> show l <> "/document/" <> show i
appPath (Corpus s i) = "corpus/" <> show s <> "/" <> show i
appPath (Corpus s i) = "corpus/" <> show s <> "/" <> show i
appPath (CorpusCode s i) = "corpusCode/" <> show s <> "/" <> show i
appPath (CorpusCode s i) = "corpusCode/" <> show s <> "/" <> show i
...
...
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