Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
cache public user
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Dec 11, 2023
1 parent c301daa commit 8ea06fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/modules/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, *args, **kwargs):
raise ValueError('User must have a password')
super().__init__(*args, **kwargs)

_public_user = None
guid = db.Column(
db.GUID, default=uuid.uuid4, primary_key=True
) # pylint: disable=invalid-name
Expand Down Expand Up @@ -844,12 +845,15 @@ def initial_random_password(cls):

@classmethod
def get_public_user(cls):
return User.ensure_user(
if cls._public_user:
return cls._public_user
cls._public_user = User.ensure_user(
email=User.PUBLIC_USER_EMAIL,
password=User.initial_random_password(),
full_name='Public User',
is_internal=True,
)
return cls._public_user

def is_public_user(self):
return self.email == User.PUBLIC_USER_EMAIL
Expand Down

0 comments on commit 8ea06fa

Please sign in to comment.