account_service.py: 导入re库使用正则匹配过滤了注册时用户名的非法字符
parent
5844eab6d5
commit
59d95d8e9f
|
@ -1,5 +1,6 @@
|
||||||
from flask import *
|
from flask import *
|
||||||
from Login import check_username_availability, verify_user, add_user, get_expiry_date, change_password
|
from Login import check_username_availability, verify_user, add_user, get_expiry_date, change_password
|
||||||
|
import re
|
||||||
|
|
||||||
# 初始化蓝图
|
# 初始化蓝图
|
||||||
accountService = Blueprint("accountService", __name__)
|
accountService = Blueprint("accountService", __name__)
|
||||||
|
@ -19,6 +20,7 @@ def signup():
|
||||||
# POST方法需判断是否注册成功,再根据结果返回不同的内容
|
# POST方法需判断是否注册成功,再根据结果返回不同的内容
|
||||||
username = escape(request.form['username'])
|
username = escape(request.form['username'])
|
||||||
password = escape(request.form['password'])
|
password = escape(request.form['password'])
|
||||||
|
|
||||||
#! 添加如下代码为了过滤注册时的非法字符
|
#! 添加如下代码为了过滤注册时的非法字符
|
||||||
if len(username) > 20:
|
if len(username) > 20:
|
||||||
return '用户名过长'
|
return '用户名过长'
|
||||||
|
|
Loading…
Reference in New Issue