本文整理汇总了Python中pdoauth.models.User.User.getByDigest方法的典型用法代码示例。如果您正苦于以下问题:Python User.getByDigest方法的具体用法?Python User.getByDigest怎么用?Python User.getByDigest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdoauth.models.User.User
的用法示例。
在下文中一共展示了User.getByDigest方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deleteDigestFromOtherUsers
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def deleteDigestFromOtherUsers(self, user, digest):
if digest:
users = User.getByDigest(digest)
for anotherUser in users:
if anotherUser.email != user.email:
anotherUser.hash = None
anotherUser.save()
示例2: getUserForEmailAndOrHash
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def getUserForEmailAndOrHash(self, digest: Digest, email: Union[str,None]):
if email:
user = User.getByEmail(email)
self.checkUserAgainsDigest(digest, user)
return user
users = User.getByDigest(digest)
self.assureExactlyOneUserInList(users)
return users[0]
示例3: getUserForEmailAndOrHash
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def getUserForEmailAndOrHash(self, digest, email):
if email:
user = User.getByEmail(email)
self.deleteDigestFromOtherUsers(user, digest)
self.checkUserAgainsDigest(digest, user)
return user
users = User.getByDigest(digest)
self.assureExactlyOneUserInList(users)
return users[0]
示例4: getUserForEmailAndOrHash
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def getUserForEmailAndOrHash(self, digest: Digest, email: Union[str,None]):
if email:
user = User.getByEmail(email)
if user is None:
raise ReportedError([noSuchUser], 400)
self.checkUserAgainsDigest(digest, user)
return user
users = User.getByDigest(digest)
self.assureExactlyOneUserInList(users)
return users[0]
示例5: checkHashInOtherUsers
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def checkHashInOtherUsers(self, user: User, additionalInfo: dict, digest: Digest) -> None:
if digest is None:
return
anotherUsers = User.getByDigest(digest)
assuredCollision = False
if anotherUsers:
for aUser in anotherUsers:
if self.handAssured(aUser):
self.sendHashCollisionMail(aUser, assured=True, inAssurance=False)
assuredCollision = True
else:
self.sendHashCollisionMail(aUser, assured=False, inAssurance=False)
if assuredCollision:
raise ReportedError([anotherUserUsingYourHash])
additionalInfo["message"] = anotherUserUsingYourHash
示例6: deleteDigestFromOtherUsers
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def deleteDigestFromOtherUsers(self, user: User) -> int:
digest = user.hash
numOfOthers = 0
assuredCollision = False
if digest:
users = User.getByDigest(digest)
for anotherUser in users:
if anotherUser.email != user.email:
anotherUser.hash = None
anotherUser.save()
numOfOthers += 1
if self.handAssured(anotherUser):
self.sendHashCollisionMail(anotherUser, assured=True, inAssurance=True)
assuredCollision = True
if assuredCollision:
message = [otherUsersWithYourHash, numOfOthers]
raise ReportedError(message)
return numOfOthers
示例7: _do_registration
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def _do_registration(self, form):
additionalInfo = {}
digest = form.digest.data
if digest == '':
digest = None
if digest is not None:
anotherUsers = User.getByDigest(form.digest.data)
if anotherUsers:
if self.isAnyoneHandAssurredOf(anotherUsers):
raise ReportedError([anotherUserUsingYourHash], 400)
additionalInfo["message"] = anotherUserUsingYourHash
user = CredentialManager.create_user_with_creds(
form.credentialType.data,
form.identifier.data,
form.secret.data,
form.email.data,
digest)
self.sendPasswordVerificationEmail(user)
user.set_authenticated()
user.activate()
r = self.loginUserInFramework(user)
if r:
return self.returnUserAndLoginCookie(user, additionalInfo)
示例8: test_getByDigest_does_not_allow_null_digest
# 需要导入模块: from pdoauth.models.User import User [as 别名]
# 或者: from pdoauth.models.User.User import getByDigest [as 别名]
def test_getByDigest_does_not_allow_null_digest(self):
with self.assertRaises(ReportedError) as context:
User.getByDigest(None)
self.assertEqual(noHashGiven,context.exception.descriptor)