chore(admin): tweak ldap view
This commit is contained in:
parent
76d3c57658
commit
b4a8ccf9cc
@ -12,11 +12,10 @@ module Handler.Admin.Ldap
|
||||
import Import
|
||||
-- import qualified Control.Monad.State.Class as State
|
||||
-- import Data.Aeson (encode)
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.Encoding as Text
|
||||
-- import qualified Data.Set as Set
|
||||
import Foundation.Yesod.Auth (decodeLdapUserTest,ldapLookupAndUpsert,CampusUserConversionException())
|
||||
import Foundation.Yesod.Auth (decodeUserTest,ldapLookupAndUpsert,UserConversionException())
|
||||
import Handler.Utils
|
||||
|
||||
import qualified Ldap.Client as Ldap
|
||||
@ -34,10 +33,10 @@ postAdminLdapR = do
|
||||
ldapPool' <- getsYesod $ view _appLdapPool
|
||||
case ldapPool' of
|
||||
Nothing -> addMessage Error (text2Html "LDAP Configuration missing.") >> return Nothing
|
||||
Just ldapPool -> do
|
||||
Just ldapPool@(ldapConf, _) -> do
|
||||
addMessage Info $ text2Html "Input for LDAP test received."
|
||||
ldapData <- ldapUser'' ldapPool lid
|
||||
decodedErr <- decodeLdapUserTest (pure $ CI.mk lid) $ concat ldapData
|
||||
ldapData <- ldapUser'' ldapPool lid
|
||||
decodedErr <- decodeUserTest UpsertUserDataLdap{ upsertUserLdapConf = ldapConf, upsertUserLdapData = concat ldapData }
|
||||
whenIsLeft decodedErr $ addMessageI Error
|
||||
return ldapData
|
||||
mbLdapData <- formResultMaybe presult procFormPerson
|
||||
@ -45,7 +44,7 @@ postAdminLdapR = do
|
||||
|
||||
((uresult, uwidget), uenctype) <- runFormPost $ identifyForm ("adminLdapUpsert"::Text) $ \html ->
|
||||
flip (renderAForm FormStandard) html $ areq textField (fslI MsgAdminUserIdent) Nothing
|
||||
let procFormUpsert :: Text -> Handler (Maybe (Either CampusUserConversionException (Entity User)))
|
||||
let procFormUpsert :: Text -> Handler (Maybe (Either UserConversionException (Entity User)))
|
||||
procFormUpsert lid = pure <$> runDB (try $ ldapLookupAndUpsert lid)
|
||||
mbLdapUpsert <- formResultMaybe uresult procFormUpsert
|
||||
|
||||
|
||||
Reference in New Issue
Block a user