Skip to content

Commit

Permalink
Adding phone number field
Browse files Browse the repository at this point in the history
  • Loading branch information
Riveong committed Dec 8, 2023
1 parent b69ed2e commit 5e8d36a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
12 changes: 8 additions & 4 deletions app/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def post_history_user(data: HistorySchema, email):
"date":date
}

def put_profile_user(data: UserSchema, email):
def put_profile_user(data: UserUpdateSchema, email):
old = get_profile_user_List(email)
uuid = old[0][0]
if (data.fullname == None):
Expand All @@ -342,12 +342,16 @@ def put_profile_user(data: UserSchema, email):
password = old[0][9]
elif(data.password != None):
password = password_encryption(data.password)
if (data.noTelp == None):
noTelp = old[0][3]
elif(data.noTelp != None):
noTelp = data.noTelp

old = None
mydb=defineDB()
mycursor = mydb.cursor()
query = ("UPDATE User SET Nama = %s, Picture = %s, Password = %s, hasPenis = %s WHERE email = %s")
res = (name, photoURL, password, gender, email)
query = ("UPDATE User SET Nama = %s, Picture = %s, Password = %s, hasPenis = %s, NoTelp = %s WHERE email = %s")
res = (name, photoURL, password, gender,noTelp, email)
mycursor.execute(query, res)
mydb.commit()
mycursor.close()
Expand All @@ -364,7 +368,7 @@ def put_profile_user(data: UserSchema, email):
"email": email,
"gender": gender,
"photoURL": photoURL,
"noTelp": ""
"noTelp": noTelp
}
}

19 changes: 19 additions & 0 deletions app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ class Config:
}
}

class UserUpdateSchema(BaseModel):
fullname : str = Field(default = None)
email : EmailStr = Field(default = None)
password : bytes = Field(default = None)
hasPenis : bool = Field(default = None)
PhotoURL : str = Field(default = None)
noTelp : str = Field(default=None)
class Config:
the_schema = {
"user_demo": {
"fullname":"deez",
"email":"[email protected]",
"password":"123",
"hasPenis":True,
"PhotoURL":"https://inilinkphotocoy.com/jpegorsomething",
"noTelp":"837491384141224"
}
}



class UserLoginSchema(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def get_profile(request: Request):
except: raise HTTPException(status_code=469, detail="AUTH NOT REAL SIR (´。_。`)")

@app.put("/user/editprofile", dependencies=[Depends(jwtBearer())], tags=["profile"])
async def put_profile(request: Request, user : UserSchema = Body(...)):
async def put_profile(request: Request, user : UserUpdateSchema = Body(...)):

authorization_header = request.headers["Authorization"]
token2 = authorization_header.split(" ")[1]
Expand Down

0 comments on commit 5e8d36a

Please sign in to comment.