Spaces:
Runtime error
Runtime error
远兮
commited on
Commit
·
033f13b
1
Parent(s):
b47ad38
fix {code:}
Browse files- redis/test_user_redis.py +3 -3
redis/test_user_redis.py
CHANGED
@@ -28,7 +28,7 @@ def send_verification_code(email, code):
|
|
28 |
|
29 |
|
30 |
# 用户请求发送验证码
|
31 |
-
@app.route('/
|
32 |
def send_verification_code_endpoint():
|
33 |
# 从请求中获取邮箱地址
|
34 |
email = request.json.get('email')
|
@@ -57,11 +57,11 @@ def register():
|
|
57 |
# 检查验证码是否匹配
|
58 |
stored_code = redis.get(email)
|
59 |
if stored_code is None or verification_code != stored_code.decode('utf-8'):
|
60 |
-
return jsonify({'message': 'Invalid verification code'})
|
61 |
|
62 |
# 检查用户名是否已被注册
|
63 |
if redis.hexists('users', username):
|
64 |
-
return jsonify({'message': 'Username already exists'})
|
65 |
|
66 |
# 生成唯一的用户ID
|
67 |
user_id = str(uuid.uuid4())
|
|
|
28 |
|
29 |
|
30 |
# 用户请求发送验证码
|
31 |
+
@app.route('/sendRegisterEmailCode', methods=['POST'])
|
32 |
def send_verification_code_endpoint():
|
33 |
# 从请求中获取邮箱地址
|
34 |
email = request.json.get('email')
|
|
|
57 |
# 检查验证码是否匹配
|
58 |
stored_code = redis.get(email)
|
59 |
if stored_code is None or verification_code != stored_code.decode('utf-8'):
|
60 |
+
return jsonify({'code': 400, 'message': 'Invalid verification code'})
|
61 |
|
62 |
# 检查用户名是否已被注册
|
63 |
if redis.hexists('users', username):
|
64 |
+
return jsonify({'code': 400, 'message': 'Username already exists'})
|
65 |
|
66 |
# 生成唯一的用户ID
|
67 |
user_id = str(uuid.uuid4())
|