Commit 65df5cfc authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[sessions] log error when it happens, on forgot user pass

parent 70d8e46d
Pipeline #2825 failed with stage
in 0 seconds
......@@ -115,18 +115,18 @@ postAuthRequest :: Backend -> AuthRequest -> Aff (Either String Session)
postAuthRequest backend ar@(AuthRequest {username}) =
decode <$> REST.post Nothing (toUrl backend "auth") ar
where
decode (Left _err) = Left "Error when sending REST.post"
decode (Left err) = Left $ "Error when sending REST.post: " <> show err
decode (Right (AuthResponse ar2))
| {inval: Just (AuthInvalid {message})} <- ar2 = Left message
| {valid: Just (AuthData {token, tree_id, user_id})} <- ar2 =
Right $ Session { backend, caches: Map.empty, token, treeId: tree_id, username, userId: user_id }
| otherwise = Left "Invalid response from server"
postForgotPasswordRequest :: Backend -> String -> Aff (Either String String)
postForgotPasswordRequest :: Backend -> String -> Aff (Either String { status :: String })
postForgotPasswordRequest backend email =
decode <$> REST.post Nothing (toUrl backend "forgotPassword") { email }
where
decode (Left _err) = Left "Error when sending REST.post"
decode (Left err) = Left $ "Error when sending REST.post: " <> show err
decode (Right s) = Right s
get :: forall a p. JSON.ReadForeign a => ToUrl Session p =>
......
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