[Twisted-Python] possible patch for twisted.mail.protocols
Matthew R. Scott
twisted at goldenspud.com
Tue Aug 5 16:37:43 MDT 2003
I am writing a custom POP-toaster type of application using as much of
existing twisted infrastructure as possible...
I found a spot in the twisted.mail.protocols.VirtualPOP3 class that does the
"right thing" when you log into the server using APOP but then does the
"wrong thing" when you try to use traditional USER/PASS login.
Here is the patch for the changes I made to make both do the "right thing".
Basically, authenticateUserAPOP and authenticateUserPASS now do the same
thing to get the portal associated with the domain; the only difference now
is how they call portal.login
This probably explains the user at domain problem I had described last week, to
which I got a response that assumed that logging in with user at domain was
working correctly :)
I ran 'trail twisted.test' and no mail-related tests failed...
$ cvs diff -nau
Index: twisted/mail/protocols.py
===================================================================
RCS file: /cvs/Twisted/twisted/mail/protocols.py,v
retrieving revision 1.16
diff -a -u -n -a -u -r1.16 protocols.py
cvs server: conflicting specifications of output style
cvs server: conflicting specifications of output style
--- twisted/mail/protocols.py 15 Jul 2003 00:07:35 -0000 1.16
+++ twisted/mail/protocols.py 5 Aug 2003 22:16:18 -0000
@@ -168,12 +168,17 @@
)
def authenticateUserPASS(self, user, password):
- portal = self.service.defaultPortal()
- return portal.login(
- cred.credentials.UsernamePassword(user, password),
- None,
- pop3.IMailbox
- )
+ user, domain = self.lookupDomain(user)
+ try:
+ portal = self.service.lookupPortal(domain)
+ except KeyError:
+ return defer.fail(cred.error.UnauthorizedLogin())
+ else:
+ return portal.login(
+ cred.credentials.UsernamePassword(user, password),
+ None,
+ pop3.IMailbox,
+ )
def lookupDomain(self, user):
try:
--
Matthew R. Scott
OMAjA / http://www.omaja.com/
More information about the Twisted-Python
mailing list