File size: 1,536 Bytes
c4dc0b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from fastapi import APIRouter
from fastapi.responses import JSONResponse
import sqlite3
from pydantic import BaseModel
class DataType(BaseModel):
    Email:str
    Password:str
GetUserDataRouter=APIRouter(prefix="/Users")
@GetUserDataRouter.post("/GetUserData")
def adduser(Dat:DataType):
    try:
        State=False
        connect=sqlite3.connect("DataBase/DataBase.bd")
        cursor=connect.execute(f'''

                        SELECT UserId,Password FROM Users where Email='{Dat.Email}'

                        ''')

        Data=cursor.fetchall()
        if len(Data)!=0:
            if Data[0][0]==None:
                return  {"Status":False,"Message":"Email or Password Is Incorrect "}
        
        HasedPassword=Data[0][1]
        UserId=Data[0][0]
        State=Dat.Password==HasedPassword
        if not State:
            return {"Status":False,"Message":"Email or Password is not correct"}
        
        cursor=connect.execute(f'''

                            

                        SELECT UserName,Job,Phonenumber,Place,BDay FROM Users where UserId={UserId}

                        ''')
        Data=cursor.fetchone()
        if len(Data)!=0:
            
            if Data[0][0]==None:
                return  {"Status":True,"Message":"Error  Not Found"}
            else:
                return  {"Status":True,"Data":Data}
        
        return {"Status":False,"Message":"Error Not Found"}
    except Exception as e:
        return {"Status":False,"Message":e}