Define user registration as a synchronous function
This commit is contained in:
parent
f470f8bff7
commit
31e0a70845
|
@ -9,7 +9,7 @@ router = APIRouter()
|
|||
|
||||
|
||||
@router.post("/register")
|
||||
async def create_user(request: UserCreate, db: Session = Depends(get_db)):
|
||||
def create_user(request: UserCreate, db: Session = Depends(get_db)):
|
||||
insert_data(model="Users", data=request, db=db)
|
||||
send_otp(receiver=request.mobile)
|
||||
return {"message": "User created, pending OTP verification"}
|
||||
|
|
|
@ -4,20 +4,20 @@ from constants import ACCOUNT_ID, TOKEN, SMS_SENDER
|
|||
from database.crud import save_otp
|
||||
|
||||
|
||||
async def connect_api():
|
||||
def connect_api():
|
||||
account_sid = ACCOUNT_ID
|
||||
auth_token = TOKEN
|
||||
client = Client(account_sid, auth_token)
|
||||
return client
|
||||
|
||||
|
||||
async def generate_code():
|
||||
def generate_code():
|
||||
bits = 16
|
||||
code = randbits(bits)
|
||||
return code
|
||||
|
||||
|
||||
async def send_otp(receiver):
|
||||
def send_otp(receiver):
|
||||
client = connect_api()
|
||||
code = generate_code()
|
||||
message = "Your OTP code is {0}".format(code)
|
||||
|
|
Loading…
Reference in New Issue