summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-11-14 21:45:51 -0500
committerLLLL Colonq <llll@colonq>2024-11-14 21:45:51 -0500
commite7d4b428708b0fa74140a7a0af7d4cab1912bdf4 (patch)
tree6218f333c86ac18d6a8cb47d235cfe4751d42f3f /fig-web/src/Fig/Web
parenta3991ddb8f61955c5c48ac99b6eed14d5e9f986a (diff)
Log errors more better
Diffstat (limited to 'fig-web/src/Fig/Web')
-rw-r--r--fig-web/src/Fig/Web/LDAP.hs42
1 files changed, 23 insertions, 19 deletions
diff --git a/fig-web/src/Fig/Web/LDAP.hs b/fig-web/src/Fig/Web/LDAP.hs
index e9861a9..97fa9d1 100644
--- a/fig-web/src/Fig/Web/LDAP.hs
+++ b/fig-web/src/Fig/Web/LDAP.hs
@@ -16,24 +16,28 @@ resetUserPassword :: MonadIO m => Config -> Text -> Text -> m (Maybe Text)
resetUserPassword cfg user uid = do
let login = Text.toLower user
password <- UUID.toText <$> liftIO UUID.nextRandom
- exitCode <- liftIO $ Proc.withCreateProcess
- (Proc.proc cfg.lldapCli $ unpack <$>
- [ "-H", cfg.lldapHost
- , "-D", cfg.lldapUser
- , "-w", cfg.lldapPassword
- , "user", "add", login, login <> "@users.colonq.computer"
- , "-p", password
- , "-f", uid
- ])
- \_ _ _ h -> Proc.waitForProcess h
- liftIO $ Proc.withCreateProcess
- (Proc.proc cfg.lldapCli $ unpack <$>
- [ "-H", cfg.lldapHost
- , "-D", cfg.lldapUser
- , "-w", cfg.lldapPassword
- , "user", "group", "add", login, "fig_users"
- ])
- \_ _ _ h -> void $ Proc.waitForProcess h
+ (exitCode, out0, err0) <- liftIO . flip Proc.readCreateProcessWithExitCode ""
+ . Proc.proc cfg.lldapCli $ unpack <$>
+ [ "-H", cfg.lldapHost
+ , "-D", cfg.lldapUser
+ , "-w", cfg.lldapPassword
+ , "user", "add", login, login <> "@users.colonq.computer"
+ , "-p", password
+ , "-f", uid
+ ]
+ (_, out1, err1) <- liftIO . flip Proc.readCreateProcessWithExitCode ""
+ . Proc.proc cfg.lldapCli $ unpack <$>
+ [ "-H", cfg.lldapHost
+ , "-D", cfg.lldapUser
+ , "-w", cfg.lldapPassword
+ , "user", "group", "add", login, "fig_users"
+ ]
case exitCode of
ExitSuccess -> pure $ Just password
- ExitFailure _ -> pure Nothing
+ ExitFailure _ -> do
+ log . pack $ mconcat
+ [ "LDAP CLI error:\n"
+ , out0, err0
+ , out1, err1
+ ]
+ pure Nothing