Spaces:
Sleeping
Sleeping
Update Logic/Locations/SetLocationForUser.py
Browse files
Logic/Locations/SetLocationForUser.py
CHANGED
|
@@ -11,7 +11,7 @@ class DataType(BaseModel):
|
|
| 11 |
Houre:str
|
| 12 |
UserAddLocationRouter=APIRouter(prefix="/Location")
|
| 13 |
@UserAddLocationRouter.post("/AddLocation")
|
| 14 |
-
def adduser(
|
| 15 |
# try:
|
| 16 |
|
| 17 |
State=False
|
|
@@ -21,7 +21,7 @@ def adduser(Data:DataType):
|
|
| 21 |
|
| 22 |
connect=sqlite3.connect("DataBase/DataBase.bd")
|
| 23 |
cursor=connect.execute(f'''
|
| 24 |
-
SELECT UserId,Password FROM Users where Email='{
|
| 25 |
''')
|
| 26 |
Data=cursor.fetchall()
|
| 27 |
if len(Data) !=0 :
|
|
@@ -29,10 +29,10 @@ def adduser(Data:DataType):
|
|
| 29 |
return {"Status":True,"Message":"User Is Not Defined Before"}
|
| 30 |
HasedPassword=Data[0][1]
|
| 31 |
UserId=Data[0][0]
|
| 32 |
-
State=
|
| 33 |
if State:
|
| 34 |
connect.execute(f'''
|
| 35 |
-
INSERT INTO TrackeringPoints (UserId,Longtude ,Lattitude,Day,Houre) VALUES ({UserId},{float(
|
| 36 |
''')
|
| 37 |
connect.commit()
|
| 38 |
connect.close()
|
|
|
|
| 11 |
Houre:str
|
| 12 |
UserAddLocationRouter=APIRouter(prefix="/Location")
|
| 13 |
@UserAddLocationRouter.post("/AddLocation")
|
| 14 |
+
def adduser(Dat:DataType):
|
| 15 |
# try:
|
| 16 |
|
| 17 |
State=False
|
|
|
|
| 21 |
|
| 22 |
connect=sqlite3.connect("DataBase/DataBase.bd")
|
| 23 |
cursor=connect.execute(f'''
|
| 24 |
+
SELECT UserId,Password FROM Users where Email='{Dat.Email}'
|
| 25 |
''')
|
| 26 |
Data=cursor.fetchall()
|
| 27 |
if len(Data) !=0 :
|
|
|
|
| 29 |
return {"Status":True,"Message":"User Is Not Defined Before"}
|
| 30 |
HasedPassword=Data[0][1]
|
| 31 |
UserId=Data[0][0]
|
| 32 |
+
State=Dat.Password==HasedPassword
|
| 33 |
if State:
|
| 34 |
connect.execute(f'''
|
| 35 |
+
INSERT INTO TrackeringPoints (UserId,Longtude ,Lattitude,Day,Houre) VALUES ({UserId},{float(Dat.Longtude)},{float(Dat.Lattitude)},'{Dat.Day}','{Dat.Houre}')
|
| 36 |
''')
|
| 37 |
connect.commit()
|
| 38 |
connect.close()
|