def application(app_id=None):
"""Register an application client."""
form = ApplicationFrom()
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 client:
flash(
f"You aready have registered application '{client.name}' and issued API credentials.",
"info")
return redirect(url_for("api_credentials", app_id=client.id))
if form.validate_on_submit():
client = Client(org_id=current_user.organisation.id)
form.populate_obj(client)
client.client_id = secrets.token_hex(10)
client.client_secret = secrets.token_urlsafe(20)
client.save()
flash(f"Application '{client.name}' was successfully registered.", "success")
return redirect(url_for("api_credentials", app_id=client.id))
return render_template("application.html", form=form)
views.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录