|
|
|
|
@ -24,11 +24,27 @@ def int_jwt_required(f):
|
|
|
|
|
|
|
|
|
|
auth_bp = Blueprint('auth', __name__)
|
|
|
|
|
|
|
|
|
|
@auth_bp.route('/code', methods=['GET'])
|
|
|
|
|
def send_email_verification_code(email: str = "3310207578@qq.com", purpose: str = 'register'):
|
|
|
|
|
email = "3310207578@qq.com"
|
|
|
|
|
send_verification_code(email, purpose=purpose)
|
|
|
|
|
return jsonify({'message': '验证码已发送'}), 200
|
|
|
|
|
@auth_bp.route('/code', methods=['POST'])
|
|
|
|
|
def send_email_verification_code():
|
|
|
|
|
"""发送邮箱验证码"""
|
|
|
|
|
try:
|
|
|
|
|
data = request.get_json()
|
|
|
|
|
email = data.get('email')
|
|
|
|
|
purpose = data.get('purpose', 'register')
|
|
|
|
|
|
|
|
|
|
if not email:
|
|
|
|
|
return jsonify({'error': '邮箱不能为空'}), 400
|
|
|
|
|
|
|
|
|
|
# 验证邮箱格式
|
|
|
|
|
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
|
|
|
|
|
if not re.match(email_pattern, email):
|
|
|
|
|
return jsonify({'error': '邮箱格式不正确'}), 400
|
|
|
|
|
|
|
|
|
|
send_verification_code(email, purpose=purpose)
|
|
|
|
|
return jsonify({'message': '验证码已发送'}), 200
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return jsonify({'error': f'发送验证码失败: {str(e)}'}), 500
|
|
|
|
|
|
|
|
|
|
@auth_bp.route('/register', methods=['POST'])
|
|
|
|
|
def register():
|
|
|
|
|
|