diff --git a/source/Network/Xmpp/Concurrent.hs b/source/Network/Xmpp/Concurrent.hs index b2f32da..4344875 100644 --- a/source/Network/Xmpp/Concurrent.hs +++ b/source/Network/Xmpp/Concurrent.hs @@ -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 diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index 55f048f..92d9a40 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -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