You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
647 B

import re
from tortoise import fields, models
class PasswordSecureMode(models.Model):
name = fields.CharField(max_length = 100)
regex = fields.CharField(max_length = 255)
checked = fields.BooleanField(default = False)
comment = fields.CharField(null = True, max_length = 255)
class Meta:
table = 'password_secure_modes'
table_description = '密码安全等级表'
@classmethod
async def verify(cls, password: str) -> bool:
mode = await PasswordSecureMode.get(checked = True)
regex = re.compile(mode.regex)
result = re.match(regex, password)
return (result is not None)