Make sure the user name is not on the black list before proceeding
parent
f9003ece69
commit
c453317ad8
|
@ -58,6 +58,12 @@ def login():
|
||||||
username = escape(request.form['username'])
|
username = escape(request.form['username'])
|
||||||
password = escape(request.form['password'])
|
password = escape(request.form['password'])
|
||||||
verified = verify_user(username, password)
|
verified = verify_user(username, password)
|
||||||
|
#读black.txt文件判断用户是否在黑名单中
|
||||||
|
with open('black.txt') as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if username == line:
|
||||||
|
return jsonify({'status': '5'})
|
||||||
with open('black.txt', 'a+') as f:
|
with open('black.txt', 'a+') as f:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
@ -65,7 +71,7 @@ def login():
|
||||||
for i in lines:
|
for i in lines:
|
||||||
line.append(i.strip('\n'))
|
line.append(i.strip('\n'))
|
||||||
#读black.txt文件判断用户是否在黑名单中
|
#读black.txt文件判断用户是否在黑名单中
|
||||||
if verified and username not in line:
|
if verified and username not in line: #TODO: 一个用户名是另外一个用户名的子串怎么办?
|
||||||
# 登录成功,写入session
|
# 登录成功,写入session
|
||||||
session['logged_in'] = True
|
session['logged_in'] = True
|
||||||
session[username] = username
|
session[username] = username
|
||||||
|
|
Loading…
Reference in New Issue