瀏覽代碼

add edit profile api and limit user_profile

ming 3 年之前
父節點
當前提交
3c9f2b5ead
共有 5 個文件被更改,包括 2 次插入2 次删除
  1. 二進制
      api/__pycache__/mailer.cpython-39.pyc
  2. 二進制
      api/__pycache__/main.cpython-39.pyc
  3. 二進制
      api/__pycache__/models.cpython-39.pyc
  4. 2 2
      api/main.py
  5. 二進制
      api/util/__pycache__/user.cpython-39.pyc

二進制
api/__pycache__/mailer.cpython-39.pyc


二進制
api/__pycache__/main.cpython-39.pyc


二進制
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

二進制
api/util/__pycache__/user.cpython-39.pyc