aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-01-25 03:03:45 +0000
committerrubenwardy <rw@rubenwardy.com>2020-01-25 03:03:45 +0000
commit19a626e2377997b23a176b4e65a33ea3e31ea467 (patch)
tree36b818984ca8212797807dc4a1da3f74247abd9b
parent43c2ee6b7b55ea864568689946c5732d16b2f722 (diff)
downloadcheatdb-19a626e2377997b23a176b4e65a33ea3e31ea467.tar.xz
Fix auto-webhook creation failure due to wrong scheme
-rw-r--r--app/blueprints/github/__init__.py6
-rw-r--r--app/tasks/emails.py3
-rw-r--r--app/templates/emails/verify.html4
-rw-r--r--app/utils.py6
4 files changed, 13 insertions, 6 deletions
diff --git a/app/blueprints/github/__init__.py b/app/blueprints/github/__init__.py
index b3be731..c65a68d 100644
--- a/app/blueprints/github/__init__.py
+++ b/app/blueprints/github/__init__.py
@@ -24,7 +24,7 @@ from sqlalchemy import func
from flask_github import GitHub
from app import github, csrf
from app.models import db, User, APIToken, Package, Permission
-from app.utils import loginUser, randomString
+from app.utils import loginUser, randomString, abs_url_for
from app.blueprints.api.support import error, handleCreateRelease
import hmac, requests, json
@@ -180,7 +180,7 @@ def setup_webhook():
if current_user.github_access_token is None:
return github.authorize("write:repo_hook", \
- redirect_uri=url_for("github.callback_webhook", pid=pid, _external=True))
+ redirect_uri=abs_url_for("github.callback_webhook", pid=pid))
form = SetupWebhookForm(formdata=request.form)
if request.method == "POST" and form.validate():
@@ -214,7 +214,7 @@ def handleMakeWebhook(gh_user, gh_repo, package, oauth, event, token):
"active": True,
"events": [event],
"config": {
- "url": url_for("github.webhook", _external=True),
+ "url": abs_url_for("github.webhook"),
"content_type": "json",
"secret": token.access_token
},
diff --git a/app/tasks/emails.py b/app/tasks/emails.py
index f81deaa..fa5a8c8 100644
--- a/app/tasks/emails.py
+++ b/app/tasks/emails.py
@@ -19,6 +19,7 @@ from flask import render_template, url_for
from flask_mail import Message
from app import mail
from app.tasks import celery
+from app.utils import abs_url_for
@celery.task()
def sendVerifyEmail(newEmail, token):
@@ -34,7 +35,7 @@ def sendVerifyEmail(newEmail, token):
If this was you, then please click this link to verify the address:
{}
- """.format(url_for('users.verify_email', token=token, _external=True))
+ """.format(abs_url_for('users.verify_email', token=token))
msg.html = render_template("emails/verify.html", token=token)
mail.send(msg)
diff --git a/app/templates/emails/verify.html b/app/templates/emails/verify.html
index 04a4bc5..925521a 100644
--- a/app/templates/emails/verify.html
+++ b/app/templates/emails/verify.html
@@ -16,12 +16,12 @@
If this was you, then please click this link to verify the address:
</p>
-<a class="btn" href="{{ url_for('users.verify_email', token=token, _external=True) }}">
+<a class="btn" href="{{ abs_url_for('users.verify_email', token=token) }}">
Confirm Email Address
</a>
<p style="font-size: 80%;">
- Or paste this into your browser: {{ url_for('users.verify_email', token=token, _external=True) }}
+ Or paste this into your browser: {{ abs_url_for('users.verify_email', token=token) }}
<p>
{% endblock %}
diff --git a/app/utils.py b/app/utils.py
index f44622d..712339b 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -22,6 +22,12 @@ from app.models import *
from app import app
import random, string, os, imghdr
+
+@app.template_filter()
+def abs_url_for(path, **kwargs):
+ scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http"
+ return url_for(path, _external=True, _scheme=scheme, **kwargs)
+
def get_int_or_abort(v, default=None):
try:
return int(v or default)