Define user registration as a synchronous function

This commit is contained in:
coolneng 2020-09-12 19:34:11 +02:00
parent f470f8bff7
commit 31e0a70845
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 4 additions and 4 deletions

View File

@ -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"}

View File

@ -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)