def register():
req = request.get_json()
if 'username' not in req or 'password' not in req \
or 'invite_code' not in req:
return jsonify({'error': 'Bad request'}), 400
username = req['username']
password = req['password']
invite_code = req['invite_code']
if not verify_invite_code(invite_code):
return jsonify({'error': 'Invalid invite code'}), 400
new_user(username, password)
Invite.query.filter(Invite.code == invite_code).first().redeemed = True
db_session.commit()
return jsonify({'success': True})
评论列表
文章目录