forked from rDrama/rDrama
fdfd
parent
46dc8c4f35
commit
c5eee81b8d
|
@ -212,77 +212,6 @@ def admin_app_id_comments(v, aid):
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def admin_apps_list(v):
|
def admin_apps_list(v):
|
||||||
|
|
||||||
apps = g.db.query(OauthApp).options(
|
apps = g.db.query(OauthApp).all()
|
||||||
joinedload(
|
|
||||||
OauthApp.author)).filter(
|
|
||||||
OauthApp.client_id==None).order_by(
|
|
||||||
OauthApp.id.desc()).all()
|
|
||||||
|
|
||||||
return render_template("admin/apps.html", v=v, apps=apps)
|
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"}
|
|
Loading…
Reference in New Issue