Przeglądaj źródła

add edit profile api and limit user_profile

ming 3 lat temu
rodzic
commit
3c9f2b5ead

BIN
api/__pycache__/mailer.cpython-39.pyc


BIN
api/__pycache__/main.cpython-39.pyc


BIN
api/__pycache__/models.cpython-39.pyc


+ 2 - 2
api/main.py

@@ -154,7 +154,7 @@ async def user_profile(token: str = Depends(oauth2_scheme)):
     str_return = json.dumps(dic_return)
     return str_return
 
-@app.post('/edit_profile', response_class=HTMLResponse)
+@app.post('/edit_profile')
 async def edit_profile(userModel : models.UserProfile ,token: str = Depends(oauth2_scheme)):
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
     print(token)
@@ -162,7 +162,7 @@ async def edit_profile(userModel : models.UserProfile ,token: str = Depends(oaut
     print(user_id)
     user_obj = next(iter(db.query('SELECT * FROM users where id ="'+str(user_id)+'"')))
     user_obj['email'] = userModel.email
-    db.query('UPDATE users SET email = "'+userModel.email+'" where id ='+str(user_id))
+    db['users'].update(user_obj,['id'])
     return {'msg':'ok'}
 
 # login & register page

BIN
api/util/__pycache__/user.cpython-39.pyc