Support Libravatar matching by OpenID URL as well as by email address
This commit is contained in:
parent
6efcc450a3
commit
4fd2ff826a
3 changed files with 33 additions and 3 deletions
|
|
@ -70,6 +70,10 @@ class User(ModelMeta, AbstractUser):
|
|||
compute_from='calc_email_sha256', max_length=64, unique=True,
|
||||
help_text="SHA-256 hash of the user's email, used for Libravatar"
|
||||
)
|
||||
openid_sha256 = ComputedCharField(
|
||||
compute_from='calc_openid_sha256', max_length=64, unique=True,
|
||||
help_text="SHA-256 hash of the user's OpenID URL, used for Libravatar"
|
||||
)
|
||||
|
||||
@property
|
||||
def calc_email_md5(self):
|
||||
|
|
@ -79,6 +83,10 @@ class User(ModelMeta, AbstractUser):
|
|||
def calc_email_sha256(self):
|
||||
return sha256(self.email.lower().encode('utf-8')).hexdigest()
|
||||
|
||||
@property
|
||||
def calc_openid_sha256(self):
|
||||
return sha256(self.full_url.encode('utf-8')).hexdigest()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return '{0} {1}'.format(self.first_name, self.last_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue