def api_credentials(app_id=None):
"""Manage API credentials."""
if app_id:
client = Client.select().where(Client.id == app_id).first()
else:
client = Client.select().where(Client.user_id == current_user.id).first()
if not client:
return redirect(url_for("application"))
form = CredentialForm(obj=client)
print(form.reset.data)
print("***", request.form)
if form.validate_on_submit():
if form.revoke.data:
Token.delete().where(Token.client == client).execute()
elif form.reset.data:
form.client_id.data = client.client_id = secrets.token_hex(10)
form.client_secret.data = client.client_secret = secrets.token_urlsafe(20)
client.save()
elif form.update_app.data:
form.populate_obj(client)
client.save()
elif form.delete.data:
Token.delete().where(Token.client == client).execute()
client.delete().execute()
return redirect(url_for("application"))
return render_template("api_credentials.html", form=form)
views.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录