Remove social connections page and restrict email settings to non-OAuth users
This commit is contained in:
parent
997fd760d2
commit
28f279a4ab
5 changed files with 13 additions and 69 deletions
|
|
@ -15,9 +15,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{% url 'account_email' %}">{% trans "E-mail Addresses" %}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'socialaccount_connections' %}">{% trans "Social connections" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
</ul>
|
||||
</li>
|
||||
{% if request.user.is_authenticated %}
|
||||
{% if not request.user.socialaccount_set.all %}
|
||||
<li class="nav-item">
|
||||
{% url 'account_email' as url %}
|
||||
<a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}">
|
||||
|
|
@ -81,6 +82,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
{% trans "Account" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'account_logout' %}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
{% extends "socialaccount/base.html" %}
|
||||
{% comment %}
|
||||
This file is part of photo21
|
||||
Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
{% load i18n %}
|
||||
{% block head_title %}{% trans "Account Connections" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans "Account" %}</h1>
|
||||
<div class="card">
|
||||
<div class="card-header pb-0 border-bottom-0">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'account_email' %}">{% trans "E-mail Addresses" %}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{% url 'socialaccount_connections' %}">{% trans "Social connections" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if form.accounts %}
|
||||
<p>{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}</p>
|
||||
|
||||
<form method="post" action="{% url 'socialaccount_connections' %}">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
{% if form.non_field_errors %}
|
||||
<div id="errorMsg">{{ form.non_field_errors }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% for base_account in form.accounts %}
|
||||
{% with base_account.get_provider_account as account %}
|
||||
<div>
|
||||
<label for="id_account_{{ base_account.id }}">
|
||||
<input id="id_account_{{ base_account.id }}" type="radio" name="account" value="{{ base_account.id }}"/>
|
||||
<span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">{{account.get_brand.name}}</span>
|
||||
{{ account }}
|
||||
</label>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
<div>
|
||||
<button type="submit">{% trans 'Remove' %}</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
<p>{% trans 'You currently have no social network accounts connected to this account.' %}</p>
|
||||
{% endif %}
|
||||
|
||||
<h2>{% trans 'Add a 3rd Party Account' %}</h2>
|
||||
|
||||
<ul class="socialaccount_providers">
|
||||
{% include "socialaccount/snippets/provider_list.html" with process="connect" %}
|
||||
</ul>
|
||||
|
||||
{% include "socialaccount/snippets/login_extra.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -17,12 +17,13 @@ from django.views.i18n import JavaScriptCatalog
|
|||
if settings.DEBUG:
|
||||
from debug_toolbar.toolbar import debug_toolbar_urls
|
||||
|
||||
from .views import IndexView, MediaAccess
|
||||
from .views import EmailView, IndexView, MediaAccess
|
||||
|
||||
urlpatterns = [
|
||||
path("select2/", include("django_select2.urls")),
|
||||
path("", IndexView.as_view(), name="index"),
|
||||
path("", include("photologue.urls", namespace="photologue")),
|
||||
path("accounts/email/", EmailView.as_view(), name="account_email"),
|
||||
path("accounts/", include("allauth.urls")),
|
||||
path("accounts/", include("allauth_oauth.urls")),
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,23 @@
|
|||
|
||||
import os
|
||||
|
||||
from allauth.account.views import EmailView as AllauthEmailView
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import FileResponse, Http404
|
||||
from django.shortcuts import redirect
|
||||
from django.views.generic import ListView, View
|
||||
from photologue.models import Gallery, Photo, Video
|
||||
|
||||
|
||||
class EmailView(AllauthEmailView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated and request.user.socialaccount_set.exists():
|
||||
return redirect("index")
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class MediaAccess(View):
|
||||
def get(self, request, path):
|
||||
if not request.user.is_authenticated:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue