sfd
This commit is contained in:
parent
62a5278af4
commit
6cc19ce02a
21 changed files with 194 additions and 194 deletions
|
@ -10,7 +10,7 @@ from files.__main__ import app
|
|||
@auth_required
|
||||
def authorize_prompt(v):
|
||||
client_id = request.args.get("client_id")
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
||||
application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first()
|
||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||
return render_template("oauth.html", v=v, application=application)
|
||||
|
||||
|
@ -21,7 +21,7 @@ def authorize_prompt(v):
|
|||
def authorize(v):
|
||||
|
||||
client_id = request.form.get("client_id")
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
||||
application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first()
|
||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||
access_token = secrets.token_urlsafe(128)[:128]
|
||||
new_auth = ClientAuth(
|
||||
|
@ -63,9 +63,9 @@ def request_api_keys(v):
|
|||
def delete_oauth_app(v, aid):
|
||||
|
||||
aid = int(aid)
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
|
||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all():
|
||||
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all():
|
||||
g.db.delete(auth)
|
||||
|
||||
g.db.delete(app)
|
||||
|
@ -81,7 +81,7 @@ def delete_oauth_app(v, aid):
|
|||
def edit_oauth_app(v, aid):
|
||||
|
||||
aid = int(aid)
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
|
||||
app.redirect_uri = request.form.get('redirect_uri')
|
||||
app.app_name = request.form.get('name')
|
||||
|
@ -99,7 +99,7 @@ def edit_oauth_app(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_approve(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
user = app.author
|
||||
|
||||
app.client_id = secrets.token_urlsafe(64)[:64]
|
||||
|
@ -126,9 +126,9 @@ def admin_app_approve(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_revoke(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
if app.id:
|
||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
|
||||
g.db.flush()
|
||||
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.")
|
||||
|
@ -145,9 +145,9 @@ def admin_app_revoke(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_reject(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
|
||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
|
||||
g.db.flush()
|
||||
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.")
|
||||
|
@ -229,7 +229,7 @@ def reroll_oauth_tokens(aid, v):
|
|||
|
||||
aid = aid
|
||||
|
||||
a = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
a = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||
|
||||
if a.author_id != v.id: abort(403)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue