remotes/1693045480750635534/spooky-22
Aevann1 2021-08-03 18:41:52 +02:00
parent 46dc8c4f35
commit c5eee81b8d
1 changed files with 2 additions and 73 deletions

View File

@ -212,77 +212,6 @@ def admin_app_id_comments(v, aid):
@admin_level_required(3)
def admin_apps_list(v):
apps = g.db.query(OauthApp).options(
joinedload(
OauthApp.author)).filter(
OauthApp.client_id==None).order_by(
OauthApp.id.desc()).all()
apps = g.db.query(OauthApp).all()
return render_template("admin/apps.html", v=v, apps=apps)
@app.post("/oauth/reroll/<aid>")
@auth_required
def reroll_oauth_tokens(aid, v):
aid = aid
a = g.db.query(OauthApp).filter_by(id=aid).first()
if a.author_id != v.id:
abort(403)
a.client_id = secrets.token_urlsafe(64)[:64]
a.client_secret = secrets.token_urlsafe(128)[:128]
g.db.add(a)
return {"message": "Tokens Rerolled", "id": a.client_id, "secret": a.client_secret}
@app.post("/oauth/rescind/<aid>")
@auth_required
@validate_formkey
def oauth_rescind_app(aid, v):
aid = aid
auth = g.db.query(ClientAuth).filter_by(id=aid).first()
if auth.user_id != v.id:
abort(403)
g.db.delete(auth)
return {"message": f"{auth.application.app_name} Revoked"}
@app.post("/release")
@auth_required
def oauth_release_auth(v):
token=request.headers.get("Authorization").split()[1]
auth = g.db.query(ClientAuth).filter_by(user_id=v.id, access_token=token).first()
if not auth:
abort(404)
if not auth.refresh_token:
abort(400)
auth.access_token_expire_utc=0
g.db.add(auth)
return {"message":"Authorization released"}
@app.post("/kill")
@auth_required
def oauth_kill_auth(v):
token=request.headers.get("Authorization").split()[1]
auth = g.db.query(ClientAuth).filter_by(user_id=v.id, access_token=token).first()
if not auth:
abort(404)
g.db.delete(auth)
return {"message":"Authorization released"}
return render_template("admin/apps.html", v=v, apps=apps)