make sure disabled user can't create new alias

This commit is contained in:
Son 2022-04-27 16:05:40 +02:00
parent f5a5a06e19
commit eab7606f93
2 changed files with 11 additions and 0 deletions

View file

@ -683,6 +683,9 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
Whether user can create a new alias. User can't create a new alias if
- has more than 15 aliases in the free plan, *even in the free trial*
"""
if self.disabled:
return False
if self.lifetime_or_active_subscription():
return True
else:

View file

@ -250,3 +250,11 @@ def test_EnumE():
assert E.get_value("A") == 100
assert E.get_value("Not existent") is None
def test_can_create_new_alias_disabled_user():
user = create_new_user()
assert user.can_create_new_alias()
user.disabled = True
assert not user.can_create_new_alias()