[FEAT] Enable django-allauth for enhanced user management & federation

This commit is contained in:
2023-02-24 19:42:07 +00:00
parent 05ca7433f1
commit 86e18c399d
58 changed files with 1248 additions and 30 deletions

View File

View File

@@ -0,0 +1,11 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Account Inactive" %}{% endblock %}
{% block content %}
<h1>{% trans "Account Inactive" %}</h1>
<p>{% trans "This account is inactive." %}</p>
{% endblock %}

View File

@@ -0,0 +1 @@
{% extends "base.html" %}

View File

@@ -0,0 +1,93 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Account Details" %}{% endblock %}
{% block content %}
<h1 class="h1" id="head_banner">Account Details</h1>
<h2 class="h2" id="head_banner">{% trans "Email Addresses" %}</h2>
{% if user.emailaddress_set.all %}
<p class="email_settings_info">{% trans 'The following email addresses are associated with your account:' %}</p>
<form action="{% url 'account_email' %}" method="post">
{% csrf_token %}
{% for emailaddress in user.emailaddress_set.all %}
<div class="ctrlHolder">
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
{{ emailaddress.email }}
{% if emailaddress.primary %}
<span class="primary">(primary email)</span>
{% endif %}
{% if not emailaddress.verified %}
<span class="unverified">(not verified)</span>
{% endif %}
<input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
</label>
</div>
{% endfor %}
<div>
<button class="btn btn-primary" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
<button class="btn btn-info" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
<button class="btn btn-danger" type="submit" name="action_remove" >{% trans 'Remove' %}</button>
</div>
</form>
{% else %}
<p class="email_settings_info"><strong>{% trans 'Warning:'%}</strong> {% trans "You do not have any email addresses set up. Please add an email address to receive notifications, reset your password, and perform other account-related actions." %}</p>
{% endif %}
<h3 class="h3" id="head_banner">{% trans "Add Email Address" %}</h3>
<form method="post" id="email_form" action="{% url 'account_email' %}">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
<button class="btn btn-primary" name="action_add" type="submit">{% trans "Add Email" %}</button>
</form>
<h2 class="h2" id="head_banner">{% trans "Change Password" %}</h2>
<a class="btn btn-primary mb-4" href="{% url 'account_change_password' %}">{% trans "Change password" %}</a>
<h2 class="h2" id="head_banner">{% trans "Federated Login" %}</h2>
<p>You can connect third-party accounts to log into this site with them.</p>
<a class="btn btn-primary" href="{% url 'socialaccount_connections' %}">{% trans "Manage" %}</a>
{% endblock %}
{% block extra_body %}
<script type="text/javascript">
(function() {
var message = "{% trans 'Are you sure you want to remove the selected email address?' %}";
var actions = document.getElementsByName('action_remove');
if (actions.length) {
actions[0].addEventListener("click", function(e) {
if (! confirm(message)) {
e.preventDefault();
}
});
}
})();
</script>
{% endblock %}

View File

@@ -0,0 +1,76 @@
{% load account %}
{% user_display user as user_display %}
{% load i18n %}
{% load inlinecss %}
{% inlinecss "css/emails.css" %}
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Your New {{ settings.PROJECT_LONG_NAME }} Account</title>
</head>
<body itemscope itemtype="http://schema.org/EmailMessage">
<table class="body-wrap">
<tr>
<td></td>
<td class="container" width="600">
<div class="content">
<table class="main" width="100%" cellpadding="0" cellspacing="0" itemprop="action" itemscope
itemtype="http://schema.org/ConfirmAction">
<tr>
<td class="content-wrap">
<meta itemprop="name" content="Confirm Email" />
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="content-block">
<h2>{{ settings.PROJECT_LONG_NAME }}</h2>
</td>
</tr><tr>
<td class="content-block">
You have a new account on {{ settings.PROJECT_LONG_NAME }}. You can log in with the button below.
</td>
</tr>
<tr>
<td class="content-block">
Your username is <i>{{ user.username }}</i>.
</td>
</tr>
<tr>
<td class="content-block" itemprop="handler" itemscope
itemtype="http://schema.org/HttpActionHandler">
<a href="{{ settings.SITE_PROTOCOL }}://{{ settings.SITE_URL }}/accounts/login/" class="btn-primary" itemprop="url">Log in</a>
</td>
</tr>
<tr>
<td class="content-block">
The {{ settings.PROJECT_SHORT_NAME }} team
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="footer">
<table width="100%">
<tr>
</tr>
</table>
</div>
</div>
</td>
<td></td>
</tr>
</table>
</body>
</html>
{% endinlinecss %}

View File

@@ -0,0 +1,10 @@
Dear user,
You have a new account on {{ settings.PROJECT_LONG_NAME }}. You can log in at the link below.
Your username is {{ user.username }}.
Log in: {{ settings.SITE_PROTOCOL }}://{{ settings.SITE_URL }}/accounts/login/
Thanks,
The {{ settings.PROJECT_SHORT_NAME }} team

View File

@@ -0,0 +1,71 @@
{% load account %}
{% user_display user as user_display %}
{% load i18n %}
{% load inlinecss %}
{% inlinecss "css/emails.css" %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Registration confirmation email</title>
</head>
<body itemscope itemtype="http://schema.org/EmailMessage">
<table class="body-wrap">
<tr>
<td></td>
<td class="container" width="600">
<div class="content">
<table class="main" width="100%" cellpadding="0" cellspacing="0" itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<tr>
<td class="content-wrap">
<meta itemprop="name" content="Confirm Email"/>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="content-block">
<h2>{{ settings.PROJECT_LONG_NAME }}</h2>
</td>
</tr>
<tr>
<td class="content-block">
Please confirm your email address by clicking the link below.
</td>
</tr>
<tr>
<td class="content-block">
We may need to send you critical information about our service, so it is important that we have your correct email address.
</td>
</tr>
<tr>
<td class="content-block" itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<a href="{{ activate_url }}" class="btn-primary" itemprop="url">Confirm email address</a>
</td>
</tr>
<tr>
<td class="content-block">
The {{ settings.PROJECT_SHORT_NAME }} team
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="footer">
<table width="100%">
<tr>
</tr>
</table>
</div></div>
</td>
<td></td>
</tr>
</table>
</body>
</html>
{% endinlinecss %}

View File

@@ -0,0 +1 @@
{% include "account/email/email_confirmation_message.html" %}

View File

@@ -0,0 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Confirm Your Registration - {{ settings.PROJECT_SHORT_NAME }}{% endblocktrans %}
{% endautoescape %}

View File

@@ -0,0 +1 @@
Confirm Your Email

View File

@@ -0,0 +1,69 @@
{% load i18n %}
{% load inlinecss %}
{% inlinecss "css/emails.css" %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Reset your Password</title>
</head>
<body itemscope itemtype="http://schema.org/EmailMessage">
<table class="body-wrap">
<tr>
<td></td>
<td class="container" width="600">
<div class="content">
<table class="main" width="100%" cellpadding="0" cellspacing="0" itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<tr>
<td class="content-wrap">
<meta itemprop="name" content="Confirm Email"/>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="content-block">
<h2>{{ settings.PROJECT_LONG_NAME }}</h2>
</td>
</tr>
<tr>
<td class="content-block">
Please reset your password by clicking the link below.
</td>
</tr>
<tr>
<td class="content-block">
We may need to send you critical information about our service, so it is important that we have your correct email address.
</td>
</tr>
<tr>
<td class="content-block" itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<a href="{{ password_reset_url }}" class="btn-primary" itemprop="url">Reset your password</a>
</td>
</tr>
<tr>
<td class="content-block">
The {{ settings.PROJECT_SHORT_NAME }} team
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="footer">
<table width="100%">
<tr>
</tr>
</table>
</div></div>
</td>
<td></td>
</tr>
</table>
</body>
</html>
{% endinlinecss %}

View File

@@ -0,0 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Reset Password - {{ settings.PROJECT_SHORT_NAME }}{% endblocktrans %}
{% endautoescape %}

View File

@@ -0,0 +1,32 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load account %}
{% block head_title %}{% trans "Confirm Email Address" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Confirm Email Address" %}</h3>
{% if confirmation %}
<p class="verification_sent_info" >{% blocktrans with confirmation.email_address.email as email %} Please confirm ownership of <a href="mailto:{{ email }}">{{ email }}</a>.{% endblocktrans %}</p>
<form method="post"action="{% url 'account_confirm_email' confirmation.key %}">
{% csrf_token %}
<button class="btn btn-success" type="submit">{% trans 'Confirm' %}</button>
</form>
{% else %}
{% url 'account_email' as email_url %}
<p class="verification_sent_info" >{% blocktrans %}This email confirmation link expired or is invalid. Please <a href="{{ email_url }}">request a new email confirmation</a>. You will be redirected to the login page in 5 seconds.{% endblocktrans %}</p>
<script>
setTimeout("location.href = '{% url 'account_login' %}';",5000);
</script>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,59 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_links %}
<title>Sign In</title>
{% endblock %}
{% block head_title %}{% trans "Sign In" %} {% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Sign In" %}</h3>
<form id="login_form" method="POST" action="{% url 'account_login' %}">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button class="btn btn-primary " type="submit">{% trans "Log in" %}</button>
<a class="btn btn-outline-dark" href="{% url 'account_reset_password' %}">{% trans "Forgot password?" %}</a>
</form>
{% if config.ENABLE_GOOGLE_LOGIN or config.ENABLE_MICROSOFT_LOGIN %}
{% load account socialaccount %}
{% get_providers as socialaccount_providers %}
<h5>Federated Login</h5>
<div class="social_providers_list">
{% for provider in socialaccount_providers %}
{% if provider.name == "Google" and config.ENABLE_GOOGLE_LOGIN or provider.name == "Microsoft Graph" and config.ENABLE_MICROSOFT_LOGIN %}
<form action="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params %}" method="post">
{% csrf_token %}
<button class="btn btn-outline-dark" type="submit">
{% if provider.name == "Microsoft Graph" %}
Microsoft
{% else %}
{{provider.name}}
{% endif %}
</button>
</form>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Sign Out" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Sign Out" %}</h3>
<p class="confirm_logout_info">{% trans 'Are you sure you want to sign out?' %}</p>
<form id="logout_form" method="post" action="{% url 'account_logout' %}">
{% csrf_token %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
{% endif %}
<button class="btn btn-success" type="submit">{% trans 'Sign Out' %}</button>
<a class="btn btn-danger" id="custom_logout_no" href="/accounts/profile/">{% trans 'No' %}</a>
</form>
{% endblock %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}You cannot remove your primary email address ({{email}}).{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Confirmation email sent to {{email}}.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}You have confirmed {{email}}.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Removed email address {{email}}.{% endblocktrans %}

View File

@@ -0,0 +1,4 @@
{% load account %}
{% load i18n %}
{% user_display user as name %}
{% blocktrans %}Successfully logged in as {{name}}.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}You have signed out.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Password successfully changed.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Password successfully set.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Primary email address set.{% endblocktrans %}

View File

@@ -0,0 +1,2 @@
{% load i18n %}
{% blocktrans %}Your primary email address must be verified.{% endblocktrans %}

View File

@@ -0,0 +1,18 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Change Password" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Change Password" %}</h3>
<form method="POST" action="{% url 'account_change_password' %}" id="change_password_form">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
<button class="btn btn-info" type="submit" name="action">{% trans "Change Password" %}</button>
</form>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
{% block content %}
{% if user.is_authenticated %}
{% include "account/snippets/already_logged_in.html" %}
{% endif %}
<h3 class="h3" id="head_banner">{% trans "Password Reset" %}</h3>
<p class="forgot_password_info" >{% trans "Forgotten your password? Enter your email address below to reset it." %}</p>
<form method="POST" id="forgot_password_form" action="{% url 'account_reset_password' %}">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
<input class="btn btn-outline-primary " type="submit" value="{% trans 'Reset Password' %}" />
</form>
<p class="forgot_password_info">{% blocktrans %}Please contact us if you are unable to reset your password.{% endblocktrans %}</p>
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Password Reset Email Sent." %}</h3>
{% if user.is_authenticated %}
{% include "account/snippets/already_logged_in.html" %}
{% block content_extra %} {% endblock %}
{% else %}
<p class="forgot_password_info">A password reset link has been sent to your email address. Please contact us if you do not receive it within a few minutes. <br> You will be redirected to <a href="{% url 'account_login' %}">sign in</a> in 5 seconds.</p>
<script>
setTimeout("location.href = '{% url 'account_login' %}';",5000);
</script>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,24 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Change Password" %}{% endblock %}
{% block content %}
<h1>{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}</h1>
{% if token_fail %}
{% url 'account_reset_password' as passwd_reset_url %}
<p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a <a href="{{ passwd_reset_url }}">new password reset</a>.{% endblocktrans %}</p>
{% else %}
{% if form %}
<form method="POST" action="{{ action_url }}">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
<input type="submit" name="action" value="{% trans 'change password' %}"/>
</form>
{% else %}
<p>{% trans 'Your password has been changed.' %}</p>
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,9 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Change Password" %}{% endblock %}
{% block content %}
<h1>{% trans "Change Password" %}</h1>
<p>{% trans 'Your password has been changed.' %}</p>
{% endblock %}

View File

@@ -0,0 +1,18 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Set Password" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Set Password" %}</h3>
<form method="POST" action="{% url 'account_set_password' %}" class="password_set">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
<input class="btn btn-outline-primary btn-lg" type="submit" name="action" value="{% trans 'Set Password' %}"/>
</form>
{% endblock %}

View File

@@ -0,0 +1,33 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Sign Up" %}{% endblock %}
{% block head_links %}
<title>Signup</title>
{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Sign Up" %}</h3>
<p class="exist_account_info">{% blocktrans %}Already have an account? Please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>
<form id="signup_form" method="post" action="{% url 'account_signup' %}">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button class="btn btn-primary" type="submit">{% trans "Sign Up" %}</button>
</form>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Sign Up Closed" %}{% endblock %}
{% block content %}
<h1>{% trans "Sign Up Closed" %}</h1>
<p>{% blocktrans with project_long_name=settings.PROJECT_LONG_NAME %}Signing up to {{ project_long_name }} is currently not permitted.{% endblocktrans %}</p>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% load i18n %}
{% load account %}
{% block content %}
{% user_display user as user_display %}
<h3 class="h3" id="head_banner">Already Logged In</h3>
<p class="forgot_password_info" >You are already logged in as {{ user_display }}.</p>
<a class="btn btn-primary mb-4" id="custom_logout_no" href="{% url 'account_email' %}">Account Details</a>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Verify Your Email Address" %}{% endblock %}
{% block content %}
<h3 class="h3" id="head_banner">{% trans "Verify Your Email Address" %}</h3>
<p id="verification_sent_info">{% blocktrans %}A verification email has been sent to your email address. Follow the link provided to activate your account. Contact us if you do not receive it within a few minutes.{% endblocktrans %}</p>
{% endblock %}

View File

@@ -0,0 +1,22 @@
{% extends "account/base.html" %}
{% load i18n %}
{% block head_title %}{% trans "Verify Your Email Address" %}{% endblock %}
{% block content %}
<h1>{% trans "Verify Your Email Address" %}</h1>
{% url 'account_email' as email_url %}
<p>{% blocktrans %}This part of the site requires us to verify that
you are who you claim to be. We therefore require you to
verify ownership of your email address. {% endblocktrans %}</p>
<p>{% blocktrans %}A verification email has been sent to your email address. Follow the link provided to activate your account. Contact us
if you do not receive it within a few minutes.{% endblocktrans %}</p>
<p>{% blocktrans %}<strong>Note:</strong> you can still <a href="{{ email_url }}">change your email address</a>.{% endblocktrans %}</p>
{% endblock %}