Remove Twitter login, disable signups
This commit is contained in:
parent
dd67ee91da
commit
472e272305
4 changed files with 56 additions and 45 deletions
11
gnuviechadmin/gnuviechadmin/auth.py
Normal file
11
gnuviechadmin/gnuviechadmin/auth.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from allauth.account.adapter import DefaultAccountAdapter
|
||||||
|
|
||||||
|
|
||||||
|
class NoNewUsersAccountAdapter(DefaultAccountAdapter):
|
||||||
|
"""
|
||||||
|
Adapter to disable allauth new signups
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def is_open_for_signup(self, request):
|
||||||
|
return False
|
|
@ -216,7 +216,6 @@ ALLAUTH_APPS = (
|
||||||
"allauth.socialaccount",
|
"allauth.socialaccount",
|
||||||
"allauth.socialaccount.providers.google",
|
"allauth.socialaccount.providers.google",
|
||||||
"allauth.socialaccount.providers.linkedin_oauth2",
|
"allauth.socialaccount.providers.linkedin_oauth2",
|
||||||
"allauth.socialaccount.providers.twitter",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Apps specific for this project go here.
|
# Apps specific for this project go here.
|
||||||
|
@ -251,9 +250,11 @@ MESSAGE_TAGS = {
|
||||||
|
|
||||||
|
|
||||||
# ######### ALLAUTH CONFIGURATION
|
# ######### ALLAUTH CONFIGURATION
|
||||||
|
ACCOUNT_ADAPTER = "gnuviechadmin.auth.NoNewUsersAccountAdapter"
|
||||||
ACCOUNT_EMAIL_REQUIRED = True
|
ACCOUNT_EMAIL_REQUIRED = True
|
||||||
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
|
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
|
||||||
LOGIN_REDIRECT_URL = "/"
|
LOGIN_REDIRECT_URL = "/"
|
||||||
|
SOCIALACCOUNT_AUTO_SIGNUP = False
|
||||||
SOCIALACCOUNT_QUERY_EMAIL = True
|
SOCIALACCOUNT_QUERY_EMAIL = True
|
||||||
# ######### END ALLAUTH CONFIGURATION
|
# ######### END ALLAUTH CONFIGURATION
|
||||||
|
|
||||||
|
|
|
@ -5,32 +5,29 @@
|
||||||
{% block page_title %}{% trans "Sign In" %}{% endblock page_title %}
|
{% block page_title %}{% trans "Sign In" %}{% endblock page_title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% get_providers as socialaccount_providers %}
|
{% get_providers as socialaccount_providers %}
|
||||||
{% if socialaccount_providers %}
|
<div class="row">
|
||||||
<p>{% blocktrans with site.name as site_name %}Please sign in with one
|
<div class="col-lg-6 col-12">
|
||||||
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
|
<form class="login form" method="POST" action="{% url 'account_login' %}">
|
||||||
for a {{site_name}} account and sign in below:{% endblocktrans %}</p>
|
|
||||||
|
|
||||||
<ul class="list-inline">
|
|
||||||
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
|
|
||||||
</ul>
|
|
||||||
<p>{% trans 'or' %}</p>
|
|
||||||
{% else %}
|
|
||||||
<p>{% blocktrans %}If you have not created an account yet, then please
|
|
||||||
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<form class="login form" method="POST" action="{% url 'account_login' %}">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form | crispy }}
|
{{ form | crispy }}
|
||||||
{% if redirect_field_value %}
|
{% if redirect_field_value %}
|
||||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="btn btn-default" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
|
<a class="btn btn-default" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
|
||||||
<button class="btn btn-primary" type="submit">{% trans "Sign In" %}</button>
|
<button class="btn btn-primary" type="submit">{% trans "Sign In" %}</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-12">
|
||||||
|
{% if socialaccount_providers %}
|
||||||
|
<ul class="list-inline">
|
||||||
|
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
{% include "socialaccount/snippets/login_extra.html" %}
|
{% include "socialaccount/snippets/login_extra.html" %}
|
||||||
{% endblock extra_js %}
|
{% endblock extra_js %}
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
{% load socialaccount %}
|
{% load socialaccount %}
|
||||||
|
|
||||||
{% get_providers as socialaccount_providers %}
|
{% get_providers as socialaccount_providers %}
|
||||||
{% for provider in socialaccount_providers %}
|
<ul class="list-unstyled">
|
||||||
{% if provider.id == "openid" %}
|
{% for provider in socialaccount_providers %}
|
||||||
{% for brand in provider.get_brands %}
|
{% if provider.id == "openid" %}
|
||||||
<li>
|
{% for brand in provider.get_brands %}
|
||||||
<a title="{{brand.name}}"
|
<li>
|
||||||
class="socialaccount_provider {{provider.id}} {{brand.id}}"
|
<a title="{{ brand.name }}"
|
||||||
|
class="socialaccount_provider {{ provider.id }} {{ brand.id }}"
|
||||||
href="{% provider_login_url provider.id openid=brand.openid_url process=process %}"
|
href="{% provider_login_url provider.id openid=brand.openid_url process=process %}"
|
||||||
>{{brand.name}}</a>
|
>{{ brand.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a title="{{provider.name}}"
|
<a title="{{ provider.name }}"
|
||||||
class="socialaccount_provider {{provider.id}}"
|
class="socialaccount_provider {{ provider.id }}"
|
||||||
href="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params %}"><i
|
href="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params %}"><i
|
||||||
class="fa fa-{% if provider.id == 'twitter' %}twitter{% elif provider.id == 'google' %}google{% elif provider.id == 'linkedin_oauth2' %}linkedin{% endif %}"></i> {{provider.name}}</a>
|
class="fa fa-{% if provider.id == 'twitter' %}twitter{% elif provider.id == 'google' %}google{% elif provider.id == 'linkedin_oauth2' %}linkedin{% endif %}"></i> {{ provider.name }}
|
||||||
</li>
|
</a>
|
||||||
{% endfor %}
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue