inventorymgr/registration.py
def generate_registration_token() -> RegistrationToken:
    """Generate a new secure registration token and persist it."""
    for _ in range(3):
        token = secrets.token_hex()
        token_obj = RegistrationToken(
            token=token, expires=_utcnow() + datetime.timedelta(days=7)
        )
        try:
            db.session.add(token_obj)
            db.session.commit()
            return token_obj
        except IntegrityError:
            db.session.rollback()
    raise RuntimeError("Failed to generate a unique token in 3 tries.")
Generate a new secure registration token and persist it.
Generate a new secure registration token and persist it.
Generate a new secure registration token and persist it .
def generate_registration_token() -> RegistrationToken:
    for _ in range(3):
        token = secrets.token_hex()
        token_obj = RegistrationToken(
            token=token, expires=_utcnow() + datetime.timedelta(days=7)
        )
        try:
            db.session.add(token_obj)
            db.session.commit()
            return token_obj
        except IntegrityError:
            db.session.rollback()
    raise RuntimeError("Failed to generate a unique token in 3 tries.")
def generate_registration_token ( ) -> RegistrationToken : for _ in range ( 3 ) : token = secrets . token_hex ( ) token_obj = RegistrationToken ( token = token , expires = _utcnow ( ) + datetime . timedelta ( days = 7 ) ) try : db . session . add ( token_obj ) db . session . commit ( ) return token_obj except IntegrityError : db . session . rollback ( ) raise RuntimeError ( "Failed to generate a unique token in 3 tries." )
Generate a new secure registration token and persist it.
Generate a new secure registration token and persist it .
"""Generate a new secure registration token and persist it."""