Browse Source

let session fail on authentication failure

master
Philipp Balzarek 13 years ago
parent
commit
14bdc12af7
  1. 9
      source/Network/Xmpp/Concurrent.hs
  2. 2
      source/Network/Xmpp/Types.hs

9
source/Network/Xmpp/Concurrent.hs

@ -134,12 +134,15 @@ session :: HostName -- ^ The hostname / realm @@ -134,12 +134,15 @@ session :: HostName -- ^ The hostname / realm
-> Maybe ([SaslHandler], Maybe Text) -- ^ SASL handlers and the desired
-- JID resource (or Nothing to let
-- the server decide)
-> IO (Either XmppFailure (Session, Maybe AuthFailure))
-> IO (Either XmppFailure Session)
session realm config mbSasl = runErrorT $ do
stream <- ErrorT $ openStream realm (sessionStreamConfiguration config)
ErrorT $ tls stream
aut <- case mbSasl of
mbAuthError <- case mbSasl of
Nothing -> return Nothing
Just (handlers, resource) -> ErrorT $ auth handlers resource stream
case mbAuthError of
Nothing -> return ()
Just _ -> throwError XmppAuthFailure
ses <- ErrorT $ newSession stream config
return (ses, aut)
return ses

2
source/Network/Xmpp/Types.hs

@ -676,6 +676,8 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream @@ -676,6 +676,8 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream
| XmppNoStream -- ^ An action that required an active
-- stream were performed when the
-- 'StreamState' was 'Closed'
| XmppAuthFailure -- ^ Authentication with the server failed
-- unrecoverably
| TlsStreamSecured -- ^ Connection already secured
| XmppOtherFailure -- ^ Undefined condition. More
-- information should be available in

Loading…
Cancel
Save