diff --git a/database/crud.py b/database/crud.py index 1eb554c..404344d 100644 --- a/database/crud.py +++ b/database/crud.py @@ -60,12 +60,16 @@ def update_otp(data: OTPResend, db): db.commit() -def activate_account(data: OTPVerify, db): - db.query(Users).filter(Users.access_key == data.access_key).update( + ) + return user + + +def activate_account(user, db): + db.query(Users).filter(Users.access_key == user.access_key).update( {Users.status: 1} ) - user = fetch_user_by_key(data=data, db=db) - return user + db.commit() + db.refresh(user) def verify_otp(data: OTPVerify, db): @@ -74,7 +78,7 @@ def verify_otp(data: OTPVerify, db): valid_time = datetime.now() < user.otp_valid_time valid_otp = matching_otp and valid_time if valid_otp: - result = activate_account(data=data, db=db) - return result + activate_account(user=user, db=db) + return user else: raise HTTPException(status_code=400, detail="The OTP is not correct")