commit 178cab31d06b6d8ee787170cc5f6148673156a8f Author: Ryan McCabe rmccabe@redhat.com Date: Sat Aug 20 14:29:56 2011 -0400
Create a local database object for users after they authenticate successfully
luci/lib/plugin_sasl2auth.py | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) --- diff --git a/luci/lib/plugin_sasl2auth.py b/luci/lib/plugin_sasl2auth.py index 7716b73..0e0158c 100644 --- a/luci/lib/plugin_sasl2auth.py +++ b/luci/lib/plugin_sasl2auth.py @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2010 Red Hat, Inc. +# Copyright (C) 2009-2011 Red Hat, Inc. # # This program is free software; you can redistribute # it and/or modify it under the terms of version 2 of the @@ -9,6 +9,11 @@ from zope.interface import implements
from repoze.who.interfaces import IAuthenticator, IMetadataProvider from repoze.who.utils import resolveDotted + +from luci.model import DBSession +from luci.model.auth import User +import transaction + from luci import sasl2auth
class Sasl2AuthPlugin(object): @@ -33,6 +38,19 @@ class Sasl2AuthPlugin(object): identity['login'], identity['password'], self.server_fqdn, self.user_realm, self.iplocalport, self.ipremoteport ): + username = identity['login'] + db_user = User.by_user_name(username) + if not db_user: + db_user = User( + user_name=username, + display_name=username, + email_address='', + ) + try: + DBSession.add(db_user) + transaction.commit() + except Exception, e: + DBSession.rollback() return identity['login']
return None
luci-commits@lists.fedorahosted.org