✨ Feat: [#10] 코드생성 및 유효기간 설정 로직 구현
This commit is contained in:
20
common/utils/codeManger.py
Normal file
20
common/utils/codeManger.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from random import randint, choices
|
||||||
|
from django.utils.timezone import now
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
import ulid, uuid
|
||||||
|
|
||||||
|
def generate_ulid():
|
||||||
|
return str(ulid.ULID())
|
||||||
|
|
||||||
|
def generate_uuid():
|
||||||
|
return str(uuid.uuid4())
|
||||||
|
|
||||||
|
allowed_char = ''.join(chr(i) for i in range(33, 127) if chr(i).isalnum())
|
||||||
|
|
||||||
|
def generate_code(code_len): # 코드 생성
|
||||||
|
code = ''.join(choices(allowed_char, k=code_len))
|
||||||
|
return code
|
||||||
|
|
||||||
|
def set_expire(minutes): # 유효기간 설정
|
||||||
|
return now() + timedelta(minutes=minutes)
|
||||||
Reference in New Issue
Block a user