Mohammedallyl commited on
Commit
a6e5916
·
verified ·
1 Parent(s): 37f0168

Update Logic/Locations/SetLocationForUser.py

Browse files
Files changed (1) hide show
  1. Logic/Locations/SetLocationForUser.py +27 -27
Logic/Locations/SetLocationForUser.py CHANGED
@@ -12,33 +12,33 @@ class DataType(BaseModel):
12
  UserAddLocationRouter=APIRouter(prefix="/Location")
13
  @UserAddLocationRouter.post("/AddLocation")
14
  def adduser(Dat:DataType):
15
- # try:
16
 
17
- State=False
18
-
19
- pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
20
-
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 :
28
- if Data[0][0]==None:
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()
39
- return {"State":True}
40
- else:
41
- return {"State":False}
42
- # except Exception as e :
43
- # return {"Status":False,"Message":e}
 
 
 
 
 
 
 
 
 
 
 
44
 
 
12
  UserAddLocationRouter=APIRouter(prefix="/Location")
13
  @UserAddLocationRouter.post("/AddLocation")
14
  def adduser(Dat:DataType):
15
+ try:
16
 
17
+ State=False
18
+
19
+ pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
20
+
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 :
28
+ if Data[0][0]==None:
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()
39
+ return {"State":True}
40
+ else:
41
+ return {"State":False}
42
+ except Exception as e :
43
+ return {"Status":False,"Message":e}
44