Merge pull request #74 from cyisfor/sophistifimacation

hiding, I mean, sophistimacatifying the instance url checking
This commit is contained in:
GCU Prosthetic Conscience 2020-06-01 10:40:42 -04:00 committed by GitHub
commit a05d09289a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -200,8 +200,16 @@ SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer"
# URL to redirect users to when not logged in # URL to redirect users to when not logged in
ANONYMOUS_HOME_URL = "about" ANONYMOUS_HOME_URL = "about"
# URL to redirect gab users to # URL to redirect galaxy brain users to
GAB_RICKROLL_URL = "https://invidio.us/watch?v=dQw4w9WgXcQ" RICKROLL_URL = "https://invidio.us/watch?v=dQw4w9WgXcQ"
# Function to check if trying to add an account should trigger a special response
def CHECK_INSTANCE_URL(url, redirect):
if "gab.com" in url:
return redirect(RICKROLL_URL)
elif "shitposter.club" in url:
return redirect(RICKROLL_URL)
# Version number displayed on about page # Version number displayed on about page
BRUTALDON_VERSION = "2.14.1" BRUTALDON_VERSION = "2.14.1"

View File

@ -392,8 +392,9 @@ def login(request):
redirect_uris = request.build_absolute_uri(reverse("oauth_callback")) redirect_uris = request.build_absolute_uri(reverse("oauth_callback"))
if form.is_valid(): if form.is_valid():
api_base_url = form.cleaned_data["instance"] api_base_url = form.cleaned_data["instance"]
if "gab.com" in api_base_url: resp = django_settings.CHECK_INSTANCE_URL(api_base_url, redirect)
return redirect(django_settings.GAB_RICKROLL_URL) if resp is not None:
return resp
tmp_base = parse.urlparse(api_base_url.lower()) tmp_base = parse.urlparse(api_base_url.lower())
if tmp_base.netloc == "": if tmp_base.netloc == "":
api_base_url = parse.urlunparse( api_base_url = parse.urlunparse(