-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2320 from DemocracyClub/remove-social-auth
Remove social auth
- Loading branch information
Showing
20 changed files
with
252 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django import forms | ||
from django.contrib.auth.models import User | ||
from django.core.exceptions import ValidationError | ||
|
||
|
||
class LoginForm(forms.Form): | ||
""" | ||
Login form for a User. | ||
""" | ||
|
||
email = forms.EmailField(required=True) | ||
|
||
def clean_email(self): | ||
""" | ||
Normalize the entered email | ||
""" | ||
email = self.cleaned_data["email"] | ||
return User.objects.normalize_email(email) | ||
|
||
|
||
class UserProfileForm(forms.ModelForm): | ||
class Meta: | ||
model = User | ||
fields = ("username",) | ||
|
||
username = forms.CharField( | ||
max_length=50, | ||
help_text="Your username is displayed publicly. We don't accept email addresses or '@' symbols", | ||
) | ||
|
||
def clean_username(self): | ||
username = self.cleaned_data["username"] | ||
|
||
if "@" in username: | ||
raise ValidationError( | ||
"Usernames can't be email addresses or contain an '@' symbol" | ||
) | ||
|
||
user = User.objects.filter(username__iexact=username) | ||
if user: | ||
raise ValidationError("A user with that username already exists.") | ||
return username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.shortcuts import redirect | ||
from django.urls import reverse | ||
from django.utils.deprecation import MiddlewareMixin | ||
|
||
|
||
class CheckProfileDetailsMiddleware(MiddlewareMixin): | ||
def process_request(self, request): | ||
if request.user.is_authenticated and not request.user.username: | ||
add_profile_url = reverse("wombles:add_profile_details") | ||
|
||
if request.path != add_profile_url: | ||
return redirect(add_profile_url) | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
|
||
<h1>Something went wrong</h1> | ||
<p>Your authentication token may have timed out. Please request a new magic link from the <a href="{% url 'wombles:login' %}">login page</a> and try again.</p> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Use the following URL to authenticate with the Democracy Club candidates site: | ||
|
||
{{ authenticate_url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %} | ||
Log in | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% if messages %} | ||
<aside class="ds-status" aria-label="Status"> | ||
<ul class="ds-stack"> | ||
{% for message in messages %} | ||
<li {% if message.tags %}class=" {{ message.tags }} ds-status-message ds-status-{{ message.level_tag }} " {% endif %}> {{ message }} </li> | ||
{% endfor %} | ||
</ul> | ||
</aside> | ||
{% else %} | ||
<h1>Login</h1> | ||
|
||
<p>Please enter your email, and we will send you a magic link URL to authenticate your account.</p> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div> | ||
{{ form.as_p }} | ||
</div> | ||
<button type="submit" class="ds-button">Login</button> | ||
</form> | ||
<p>Contributions to this site are made public and form part of an openly licenced database. | ||
<a href="{% url "help-about" %}">Find out more about our data licencing</a>.</p> | ||
|
||
{% endif %} | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
|
||
<h1>You have logged out</h1> | ||
<p>Next time you want to log in, request a new magic link from the <a href="{% url 'wombles:login:login' %}">login | ||
page</a>.</p> | ||
|
||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<form method="POST"> | ||
<h1>Update Profile</h1> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button type="submit" class="ds-button">Save</button> | ||
</form> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.