-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignature.py
67 lines (60 loc) · 2.39 KB
/
signature.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from signature_dbms import *
from flask import Flask,render_template,redirect,request,url_for,session
app = Flask(__name__)
app.secret_key = 'MKhJHJH798798kjhkjhkjGHh'
@app.route('/signIn')
def index():
return render_template('signIn.html')
@app.route('/login',methods = ['POST', 'GET'])
def login():
if request.method == 'POST':
email = request.form['enm']
password = request.form['password']
password = hasher(password)
print (email)
user = findUserByEmail(email)
if user:
if str(password) == str(user[3]):
session['logged_in'] = True
session['user_id'] = user[0]
return (redirect(("/users/{}").format(user[0])))
else:
return (redirect(url_for('success',name="sahi password de "+
str(user[3])+str(password))))
else:
return (redirect(url_for('success',name = "Error no such user")))
@app.route('/signUp')
def new_student():
return render_template('signUp.html')
@app.route('/users/<user_id>')
def renderHome(user_id):
if session['user_id']== int(user_id):
user = findUserByUser_Id(user_id)
return render_template("user_home.html",name=user[1],email=user[2],
user_id=user[0],total_balance=user[4],
approved_balance=user[6],unapproved_balance=user[5],
friendList=findFriends(user_id),groupList=findAllGroupsForUser(user_id))
else:
return redirect('/signIn')
@app.route('/addUser',methods = ['POST','GET'])
def addUser():
verify = None
if request.method == 'POST':
try:
name = request.form['nm']
email = request.form['enm']
password = request.form['password']
print (name,email,password)
verify = insertUser(name,email,password)
msg = "Added successfully"
except:
msg = "Unsuccessful try again later"
finally:
if verify is not None:
user = findUserByEmail(email)
session['logged_in'] = True
session['user_id'] = user[0]
return (redirect(("/users/{}").format(user[0])))
else:
return (redirect(url_for('success',name =
"Account for Email already exist")))