use base58 for slugs to remove doubt

This commit is contained in:
mcbloch 2022-06-01 17:18:47 +02:00
parent 426357f00d
commit 978b432d7e

View file

@ -11,9 +11,11 @@ from utils import first
from .database import db
from .user import User
BASE58_ALPHABET = \
b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def generate_slug():
alphabet = string.ascii_letters + string.digits
secret = ''.join(secrets.choice(alphabet) for i in range(7))
secret = ''.join(secrets.choice(BASE58_ALPHABET) for i in range(7))
while Order.query.filter(Order.slug == secret).first() is not None:
secret = ''.join(secrets.choice(alphabet) for i in range(7))
return secret