feat: otp table
This commit is contained in:
+21
-1
@@ -1,5 +1,6 @@
|
||||
import dotenv
|
||||
import os
|
||||
import random
|
||||
dotenv.load_dotenv()
|
||||
|
||||
DEFAULT_SKIP = 0
|
||||
@@ -11,4 +12,23 @@ DEFAULT_ORDER = "desc"
|
||||
# jwt
|
||||
JWT_ALGORITHM = os.getenv("JWT_ALGORITHM")
|
||||
JWT_SECRET = os.getenv("JWT_SECRET")
|
||||
JWT_EXPIRE_MINUTES = os.getenv("JWT_EXPIRE_MINUTES")
|
||||
JWT_EXPIRE_MINUTES = os.getenv("JWT_EXPIRE_MINUTES")
|
||||
|
||||
def generateOTP(length: int = 6) -> str:
|
||||
"""
|
||||
Generate a secure numeric OTP (One-Time Password) of specified length.
|
||||
|
||||
Args:
|
||||
length: Length of the OTP to generate (default: 6)
|
||||
|
||||
Returns:
|
||||
A string containing the generated numeric OTP
|
||||
"""
|
||||
if length < 4:
|
||||
# Ensure minimum security with at least 4 characters
|
||||
length = 4
|
||||
|
||||
# Generate a numeric OTP with exactly 'length' digits
|
||||
# This ensures we get a number with the correct number of digits
|
||||
# For example, length=6 gives a number between 100000-999999
|
||||
return str(random.randint(10**(length-1), 10**length - 1))
|
||||
Reference in New Issue
Block a user