本文整理汇总了Python中MaKaC.authentication.AuthenticatorMgr.getAvatar方法的典型用法代码示例。如果您正苦于以下问题:Python AuthenticatorMgr.getAvatar方法的具体用法?Python AuthenticatorMgr.getAvatar怎么用?Python AuthenticatorMgr.getAvatar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.authentication.AuthenticatorMgr
的用法示例。
在下文中一共展示了AuthenticatorMgr.getAvatar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeLoginProcess
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
def _makeLoginProcess(self):
# Check for automatic login
authManager = AuthenticatorMgr()
if (
authManager.isSSOLoginActive()
and len(authManager.getList()) == 1
and not Config.getInstance().getDisplayLoginPage()
):
self._redirect(urlHandlers.UHSignInSSO.getURL(authId=authManager.getDefaultAuthenticator().getId()))
return
if request.method != "POST":
return self._signInPage.display(returnURL=self._returnURL)
else:
li = LoginInfo(self._login, self._password)
av = authManager.getAvatar(li)
if not av:
return self._signInPageFailed.display(returnURL=self._returnURL)
elif not av.isActivated():
if av.isDisabled():
self._redirect(self._disabledAccountURL(av))
else:
self._redirect(self._unactivatedAccountURL(av))
return _("Your account is not active\nPlease activate it and try again")
else:
self._setSessionVars(av)
self._addExtraParamsToURL()
self._redirect(self._url)
示例2: TestAuthentication
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
class TestAuthentication(IndicoTestCase):
_requires = ['db.Database']
def setUp(self):
super(TestAuthentication, self).setUp()
with self._context("database"):
# Create few users and groups
gh = GroupHolder()
ah = AvatarHolder()
self._authMgr = AuthenticatorMgr()
for i in xrange(1, 3):
group = Group()
group.setName("fake-group-%d" % i)
group.setDescription("fake")
group.setEmail("fake-group-%[email protected]" % i)
group.setId("fake-group-%d" % i)
avatar = Avatar()
avatar.setName("fake-%d" % i)
avatar.setSurName("fake")
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("fake%[email protected]" % i)
avatar.setId("fake-%d" % i)
avatar.activateAccount()
group.addMember(avatar)
ah.add(avatar)
gh.add(group)
identity = self._authMgr.createIdentity(LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local")
self._authMgr.add(identity)
@with_context('database')
def testAvatarHolder(self):
"""
Test Avatar Holder
"""
ah = AvatarHolder()
self.assertEqual(ah.getById("fake-1").getName(), "fake-1")
self.assertEqual(ah.match({"name": "fake-1"}, searchInAuthenticators=False)[0].getEmail(), "[email protected]")
self.assertEqual(len(ah.matchFirstLetter("name", "f", searchInAuthenticators=False)), 2)
@with_context('database')
def testGroupHolder(self):
gh = GroupHolder()
ah = AvatarHolder()
self.assert_(gh.getById("fake-group-1").containsUser(ah.getById("fake-1")))
self.assertEqual(gh.match({"groupname": "fake-group-1"}, searchInAuthenticators=False)[0].getEmail(),
"[email protected]")
self.assertEqual(len(gh.matchFirstLetter("f", searchInAuthenticators=False)), 2)
@with_context('database')
def testIdentities(self):
ah = AvatarHolder()
for i in xrange(1, 3):
self.assertEqual(self._authMgr.getAvatar(LoginInfo("fake-%d" % i, "fake-%d" % i)),
ah.getById("fake-%d" % i))
示例3: _getAnswer
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
def _getAnswer(self):
li = LoginInfo( self._username, self._password )
auth = AuthenticatorMgr()
av = auth.getAvatar(li)
if not av:
from MaKaC.services.interface.rpc.common import ServiceError
raise ServiceError(message="Wrong login or password")
elif not av.isActivated():
from MaKaC.services.interface.rpc.common import ServiceError
raise ServiceError(message="Your account is not active. Please activate it and retry.")
else:
self._getSession().setUser( av )
return '%s OK %s' % (self._username, datetime.datetime.now())
示例4: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
def _process(self):
#Check for automatic login
authManager = AuthenticatorMgr()
if (authManager.isSSOLoginActive() and len(authManager.getList()) == 1 and
not Config.getInstance().getDisplayLoginPage()):
self._redirect(urlHandlers.UHSignInSSO.getURL(authId=authManager.getDefaultAuthenticator().getId()))
return
li = LoginInfo( self._login, self._password )
av = authManager.getAvatar(li)
self._responseUtil.content_type='application/json'
if not av:
return '{"success":false,"message":"User not authenticated or found"}'
elif not av.isActivated():
return '{"success":false,"message":"User not activated"}'
else:
return '{"success":true}'
示例5: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
def _process( self ):
self._disableCaching()
#Check for automatic login
auth = AuthenticatorMgr()
av = auth.autoLogin(self)
if av:
url = self._returnURL
tzUtil = timezoneUtils.SessionTZ(av)
tz = tzUtil.getSessionTZ()
self._getSession().setVar("ActiveTimezone",tz)
self._getSession().setUser( av )
if Config.getInstance().getBaseSecureURL().startswith('https://'):
url = str(url).replace('http://', 'https://')
self._redirect( url, noCache = True )
if not self._signIn:
p = signIn.WPSignIn( self )
return p.display( returnURL = self._returnURL )
else:
li = LoginInfo( self._login, self._password )
av = auth.getAvatar(li)
if not av:
p = signIn.WPSignIn( self, login = self._login, msg = _("Wrong login or password") )
return p.display( returnURL = self._returnURL )
elif not av.isActivated():
if av.isDisabled():
self._redirect(urlHandlers.UHDisabledAccount.getURL(av))
else:
self._redirect(urlHandlers.UHUnactivatedAccount.getURL(av))
return _("your account is not activate\nPlease active it and retry")
else:
url = self._returnURL
#raise(str(dir(av)))
self._getSession().setUser( av )
tzUtil = timezoneUtils.SessionTZ(av)
tz = tzUtil.getSessionTZ()
self._getSession().setVar("ActiveTimezone",tz)
if self._userId != "":
if "?" in url:
url += "&userId=%s"%self._userId
else:
url += "?userId=%s"%self._userId
if Config.getInstance().getBaseSecureURL().startswith('https://'):
url = str(url).replace('http://', 'https://')
self._redirect( url, noCache = True )
示例6: _process
# 需要导入模块: from MaKaC.authentication import AuthenticatorMgr [as 别名]
# 或者: from MaKaC.authentication.AuthenticatorMgr import getAvatar [as 别名]
def _process( self ):
li = LoginInfo( self._login, self._password )
auth = AuthenticatorMgr()
av = auth.getAvatar(li)
value = "OK"
message = ""
if not av:
value = "ERROR"
message = "Login failed"
elif not av.isActivated():
if av.isDisabled():
value = "ERROR"
message = "Acount is disabled"
else:
value = "ERROR"
message = "Acount is not activated"
else:
value = "OK"
message = "Login succesful"
self._getSession().setUser( av )
return self._createResponse(value, message)