mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-09 03:54:08 +00:00

This allows each account to have more than one email address, of which one is primary. Adding more addresses will trigger an email with a verification link (of course). The field previously known as "email" is now changed to be "primary email". Change the profile form to allow freely changing between the added addresses which one is the primary. Remove the functionality to directly change the primary email -- instead one has to add a new address first and then change to that one, which simplifies several things in the handling.
47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
class CommunityAuthOrg(models.Model):
|
|
orgname = models.CharField(max_length=100, null=False, blank=False,
|
|
help_text="Name of the organisation")
|
|
require_consent = models.BooleanField(null=False, blank=False, default=True)
|
|
|
|
def __str__(self):
|
|
return self.orgname
|
|
|
|
|
|
class CommunityAuthSite(models.Model):
|
|
name = models.CharField(max_length=100, null=False, blank=False,
|
|
help_text="Note that the value in this field is shown on the login page, so make sure it's user-friendly!")
|
|
redirecturl = models.URLField(max_length=200, null=False, blank=False)
|
|
cryptkey = models.CharField(max_length=100, null=False, blank=False,
|
|
help_text="Use tools/communityauth/generate_cryptkey.py to create a key")
|
|
comment = models.TextField(null=False, blank=True)
|
|
org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False, on_delete=models.CASCADE)
|
|
cooloff_hours = models.IntegerField(null=False, blank=False, default=0,
|
|
help_text="Number of hours a user must have existed in the systems before allowed to log in to this site")
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class CommunityAuthConsent(models.Model):
|
|
user = models.ForeignKey(User, null=False, blank=False, on_delete=models.CASCADE)
|
|
org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False, on_delete=models.CASCADE)
|
|
consentgiven = models.DateTimeField(null=False, blank=False)
|
|
|
|
class Meta:
|
|
unique_together = (('user', 'org'), )
|
|
|
|
|
|
class SecondaryEmail(models.Model):
|
|
user = models.ForeignKey(User, null=False, blank=False, on_delete=models.CASCADE)
|
|
email = models.EmailField(max_length=75, null=False, blank=False, unique=True)
|
|
confirmed = models.BooleanField(null=False, blank=False, default=False)
|
|
token = models.CharField(max_length=100, null=False, blank=False)
|
|
sentat = models.DateTimeField(null=False, blank=False, auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ('email', )
|