Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions flask-server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ def signup():
@app.route("/SignUp_post", methods=['POST'])
def register_user():
data=request.form
pw=request.form['pw']
pw_hash = hashlib.sha256(pw.encode('utf-8')).hexdigest()
if DB.insert_user(data,pw_hash):
return render_template("index.html")
pwd=request.form['pwd']
pwd_hash = hashlib.sha256(pwd.encode('utf-8')).hexdigest()
if DB.insert_user(data,pwd_hash):
return redirect(url_for('index'))
else:
flash("user id already exist!")
return render_template("index.html")
Expand All @@ -225,12 +225,12 @@ def login():
return render_template("index.html")
@app.route("/login_confirm", methods=['POST'])
def login_user():
id_=request.form['id']
pw=request.form['pw']
pw_hash = hashlib.sha256(pw.encode('utf-8')).hexdigest()
if DB.find_user(id_,pw_hash):
session['id']=id_
return redirect(url_for('list_restaurants'))
email_=request.form['email']
pwd=request.form['pwd']
pwd_hash = hashlib.sha256(pwd.encode('utf-8')).hexdigest()
if DB.find_user(email_,pwd_hash):
session['email']=email_
return redirect(url_for('index'))
else:
flash("Wrong ID or PW!")
return render_template("login.html")
Expand All @@ -248,4 +248,4 @@ def view_storelist(store_id):
'''

if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
app.run(host='0.0.0.0', debug=True)
28 changes: 15 additions & 13 deletions flask-server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ def __init__(self):
self.db = firebase.database()
firebaseEmailAuth = firebase.auth()

#회원가입

#회원가입
def insert_user(self, data, pwd):
user_info = {
"ID" : data['ID'],
"pwd" : pwd,
"nickname" : data['nickname']
"nickname" : data['nickname'],
"email" : data['email'],
"pwd" : pwd
}
if self.user_duplicate_check(str(data['ID'])):
self.db.child("user").push(user_info)
print(data)
return True
else:
return False
# if self.user_duplicate_check(str(data['email'])):
self.db.child("user").push(user_info)
print(data)
return True
# else:
# return False

def user_duplicate_check(self, id_string):
users = self.db.child("user").get()
Expand All @@ -32,20 +33,21 @@ def user_duplicate_check(self, id_string):
else:
for res in users.each():
value = res.val()
if value['ID'] == id_string:
if value['email'] == id_string:
return False
return True


#로그인 부분
def find_user(self, ID_, pwd_):
def find_user(self, email_, pwd_):
users = self.db.child("user").get()
target_value=[]
for res in users.each():
value = res.val()
if value['ID'] == ID_ and value['pwd'] == pwd_:
if value['email'] == email_ and value['pwd'] == pwd_:
return True
return False

#평균 평점 계산하고 push해주는 함수
def AverageScore(self,storename):
count = 0
Expand Down
2 changes: 0 additions & 2 deletions flask-server/static/react/js/787.ec704a7a.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion flask-server/static/react/js/787.ec704a7a.chunk.js.map

This file was deleted.

Loading