Skip to content

Commit

Permalink
Merge pull request #281 from commonknowledge/login
Browse files Browse the repository at this point in the history
Specify when you're logging in to the community forum via SSO
  • Loading branch information
janbaykara authored Jul 15, 2022
2 parents 6b546c9 + f34bade commit b8d39cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{% extends "account/modal_base.html" %}

{% load url i18n django_bootstrap5 account socialaccount %}
{% load url i18n django_bootstrap5 account socialaccount setting %}

{% block head_title %}{% trans "Sign In" %}{% endblock %}


{% block modal_content %}
{% get_providers as socialaccount_providers %}

<h1 class="text-center h2">Log In</h1>
{% oauth_application_from_query as app %}
{% if app %}
<h1 class="text-center h2">Log in to {% app.name %}</h1>
{% else %}
<h1 class="text-center h2">Log In</h1>
{% endif %}

<div class="row">

Expand Down
14 changes: 14 additions & 0 deletions app/templatetags/setting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import urllib.parse

from django import template
from django.conf import settings
Expand Down Expand Up @@ -29,3 +30,16 @@ def user_data(context):
user_data = request.user.get_analytics_data()

return {"user_data": mark_safe(json.dumps(user_data))}

@register.simple_tag
def oauth_application_from_query(takes_context=True):
try:
request = context["request"]
next = request.GET.get('next', None)
if next:
client_id = urllib.parse.urlparse(next).query.get('client_id', None)
if client_id:
app = OAuthApp.filter(client_id=client_id).first()
return app
except:
return None

0 comments on commit b8d39cd

Please sign in to comment.