def post(self):
if not "app_id" in request.json or not "app_secret" in request.json:
error = {
"code": "MISSING_APP_ID_OR_APP_SECRET"
}
return jsonify({'error': error}), 400
existing_app = App.objects.filter(app_id=request.json.get('app_id')).first()
if existing_app:
error = {
"code": "APP_ID_ALREADY_EXISTS"
}
return jsonify({'error': error}), 400
else:
# create the credentials
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(request.json.get('app_secret'), salt)
app = App(
app_id=request.json.get('app_id'),
app_secret=hashed_password
).save()
return jsonify({'result': 'ok'})
评论列表
文章目录