From 50a3fdb5dc250fd95e8db2bf32c1d74a8f5212ca Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 18:51:35 +0200 Subject: [PATCH] fddf --- drama/routes/admin.py | 10 ---- drama/routes/login.py | 7 +-- drama/routes/oauth.py | 18 ++++--- drama/templates/admin/admin_home.html | 3 +- drama/templates/admin/app_data.html | 76 --------------------------- 5 files changed, 13 insertions(+), 101 deletions(-) delete mode 100644 drama/templates/admin/app_data.html diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 21df75b5ef..8db5a2e24b 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -436,16 +436,6 @@ def admin_removed(v): ) -@app.get("/admin/appdata") -@admin_level_required(4) -def admin_appdata(v): - - return render_template( - "admin/app_data.html", - v=v, - thing=get_post(4020) - ) - @app.post("/admin/image_purge") @admin_level_required(5) def admin_image_purge(v): diff --git a/drama/routes/login.py b/drama/routes/login.py index ea0c1ab700..875c2f0088 100644 --- a/drama/routes/login.py +++ b/drama/routes/login.py @@ -135,7 +135,8 @@ def login_post(): @app.get("/@me") @auth_required def me(v): - return redirect(v.url) + if request.headers.get("Authorization"): v.json + else: redirect(v.url) @app.post("/logout") @@ -367,10 +368,6 @@ def sign_up_post(v): session["user_id"] = new_user.id session["session_id"] = token_hex(16) - redir = request.form.get("redirect", None) - - # #print(f"Signup event: @{new_user.username}") - return redirect("/") diff --git a/drama/routes/oauth.py b/drama/routes/oauth.py index 2baa4bc102..5b2885efe6 100644 --- a/drama/routes/oauth.py +++ b/drama/routes/oauth.py @@ -92,12 +92,6 @@ def edit_oauth_app(v, aid): return redirect('/settings/apps') -@app.route("/identity") -@auth_required -def api_v1_identity(v): - return v.json - - @app.post("/admin/app/approve/") @admin_level_required(3) @validate_formkey @@ -110,8 +104,16 @@ def admin_app_approve(v, aid): g.db.add(app) - u = get_account(app.author_id, v=v) - send_notification(1046, u, f"Your application `{app.app_name}` has been approved.") + access_token = secrets.token_urlsafe(128)[:128] + new_auth = ClientAuth( + oauth_client = app.id, + user_id = v.id, + access_token=access_token + ) + + g.db.add(new_auth) + + send_notification(1046, v, f"Your application `{app.app_name}` has been approved. Here's your access token: `{access_token}`") return {"message": f"{app.app_name} approved"} diff --git a/drama/templates/admin/admin_home.html b/drama/templates/admin/admin_home.html index 4ed9340508..ff0bd6798f 100644 --- a/drama/templates/admin/admin_home.html +++ b/drama/templates/admin/admin_home.html @@ -23,8 +23,7 @@ * [Remove image from imgur and from cloudflare cache](/admin/image_purge) * [Perceptive Hash Image Ban](/admin/image_ban) * [Multi Vote Analysis](/admin/alt_votes) -* [App Queue](/admin/apps) -* [App Data](/admin/appdata) +* [Apps](/admin/apps) * [Badges](/admin/badge_grant) * [Content Stats](/admin/content_stats) diff --git a/drama/templates/admin/app_data.html b/drama/templates/admin/app_data.html deleted file mode 100644 index 5ca4fba17a..0000000000 --- a/drama/templates/admin/app_data.html +++ /dev/null @@ -1,76 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -{{"SITE_NAME" | app_config}} - -{% endblock %} - -{% block content %} -
-
-
-
-
-
App Info
- -
- - - -
- -{% if thing %} - -

Info

-

{{thing.permalink}}

- - -

Author: @{{thing.author.username}}

- -{% if thing.oauth_app %} - - -
-
- -
- - - - - - - - - - -
-
- -
- - - -{% endif %} - - - -{% endif %} - - -{% endblock %} \ No newline at end of file