-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSign_in
More file actions
46 lines (35 loc) · 1.39 KB
/
Copy pathSign_in
File metadata and controls
46 lines (35 loc) · 1.39 KB
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
44
45
46
@app.route('/sign-in', methods=['POST'])
def sign_in_check2():
if request.method == 'POST':
sign_in_details = request.get_json(silent=True, force=True)
email = sign_in_details['email']
password = sign_in_details['password']
connection = mysql.connector.connect(host=HOST_NAME, user=USER_NAME, password=PASSWORD, database=DATABASE)
mycursor = connection.cursor()
sql = "SELECT email FROM users Where email=%s"
data_search = (email,)
mycursor.execute(sql, data_search)
results = mycursor.fetchall()
if results:
sql = "SELECT password FROM users Where email=%s"
data_search = (email,)
mycursor.execute(sql, data_search)
results = mycursor.fetchone()[0]
result = bcrypt.check_password_hash(results, password)
if (result):
return jsonify({
"message": "valid Email,valid Password",
"result": result
})
else:
return jsonify({
"message": "Valid Email,Wrong Password",
"result": result
})
else:
return jsonify({
"message": "Invalid Email",
"result": results
})
print(results)
connection.commit()