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
-> Maybe ([SaslHandler], Maybe Text) -- ^ SASL handlers and the desired -> Maybe ([SaslHandler], Maybe Text) -- ^ SASL handlers and the desired
-- JID resource (or Nothing to let -- JID resource (or Nothing to let
-- the server decide) -- the server decide)
-> IO (Either XmppFailure (Session, Maybe AuthFailure)) -> IO (Either XmppFailure Session)
session realm config mbSasl = runErrorT $ do session realm config mbSasl = runErrorT $ do
stream <- ErrorT $ openStream realm (sessionStreamConfiguration config) stream <- ErrorT $ openStream realm (sessionStreamConfiguration config)
ErrorT $ tls stream ErrorT $ tls stream
aut <- case mbSasl of mbAuthError <- case mbSasl of
Nothing -> return Nothing Nothing -> return Nothing
Just (handlers, resource) -> ErrorT $ auth handlers resource stream Just (handlers, resource) -> ErrorT $ auth handlers resource stream
case mbAuthError of
Nothing -> return ()
Just _ -> throwError XmppAuthFailure
ses <- ErrorT $ newSession stream config 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
| XmppNoStream -- ^ An action that required an active | XmppNoStream -- ^ An action that required an active
-- stream were performed when the -- stream were performed when the
-- 'StreamState' was 'Closed' -- 'StreamState' was 'Closed'
| XmppAuthFailure -- ^ Authentication with the server failed
-- unrecoverably
| TlsStreamSecured -- ^ Connection already secured | TlsStreamSecured -- ^ Connection already secured
| XmppOtherFailure -- ^ Undefined condition. More | XmppOtherFailure -- ^ Undefined condition. More
-- information should be available in -- information should be available in

Loading…
Cancel
Save