remotes/1693045480750635534/spooky-22
Aevann1 2021-08-03 19:16:54 +02:00
parent a4889fc79d
commit 9c358de03d
3 changed files with 3 additions and 32 deletions

View File

@ -10,12 +10,6 @@ def get_logged_in_user():
token = request.headers.get("Authorization")
if not token: return None, None
token = token.split()
if len(token) < 2: return None, None
token = token[1]
if not token: return None, None
client = g.db.query(ClientAuth).filter(ClientAuth.access_token == token).first()
x = (client.user, client) if client else (None, None)

View File

@ -10,18 +10,15 @@ from drama.__main__ import app
def authorize_prompt(v):
client_id = request.args.get("client_id")
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
if application.is_banned: return {"oauth_error": f"Application `{application.app_name}` is suspended."}, 403
redirect_uri = request.args.get("redirect_uri")
if not redirect_uri: return {"oauth_error": f"`redirect_uri` must be provided."}, 400
return render_template("oauth.html", v=v, application=application, redirect_uri=redirect_uri)
return render_template("oauth.html", v=v, application=application)
@app.post("/authorize")
@auth_required
@validate_formkey
def oauth(v):
def authorize(v):
client_id = request.form.get("client_id")
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
@ -113,7 +110,7 @@ def admin_app_approve(v, aid):
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}`")
send_notification(1046, v, f"Your application `{app.app_name}` has been approved. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next.")
return {"message": f"{app.app_name} approved"}

View File

@ -29,16 +29,6 @@
<input type="hidden" name="formkey" value="{{v.formkey}}">
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
{% if app.client_secret %}
<label for="edit-{{app.id}}-client-id" class="mb-0 w-lg-25">Client ID</label>
<input id="edit-{{app.id}}-client-id" class="form-control copy-link" type="text" name="name" value="{{app.client_id}}" data-clipboard-text="{{app.client_id}}" role="button" readonly="readonly">
<label for="edit-{{app.id}}-client-secret" class="mb-0 w-lg-25">Client Secret</label>
<a href="javascript:void(0)" id="secret-{{app.id}}-click" class="btn btn-secondary d-block" onclick="x=document.getElementById('secret-{{app.id}}-click');x.classList.add('d-none');x.classList.remove('d-block');document.getElementById('edit-{{app.id}}-client-secret').classList.remove('d-none');">Click to show</a>
<input class="d-none form-control copy-link" id="edit-{{app.id}}-client-secret" type="text" name="name" value="{{app.client_secret}}" data-clipboard-text="{{app.client_secret}}" role="button" readonly="readonly">
{% endif %}
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>
@ -72,16 +62,6 @@
<input type="hidden" name="formkey" value="{{v.formkey}}">
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
{% if app.client_secret %}
<label for="edit-{{app.id}}-client-id" class="mb-0 w-lg-25">Client ID</label>
<input id="edit-{{app.id}}-client-id" class="form-control copy-link" type="text" name="name" value="{{app.client_id}}" data-clipboard-text="{{app.client_id}}" role="button" readonly="readonly">
<label for="edit-{{app.id}}-client-secret" class="mb-0 w-lg-25">Client Secret</label>
<a href="javascript:void(0)" id="secret-{{app.id}}-click" class="btn btn-secondary d-block" onclick="x=document.getElementById('secret-{{app.id}}-click');x.classList.add('d-none');x.classList.remove('d-block');document.getElementById('edit-{{app.id}}-client-secret').classList.remove('d-none');">Click to show</a>
<input class="d-none form-control copy-link" id="edit-{{app.id}}-client-secret" type="text" name="name" value="{{app.client_secret}}" data-clipboard-text="{{app.client_secret}}" role="button" readonly="readonly">
{% endif %}
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>