-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
219 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from django.core.signing import Signer, TimestampSigner | ||
from django.core.signing import TimestampSigner | ||
|
||
ActivationSigner = TimestampSigner('email-activation-signer') | ||
ActivationSigner = TimestampSigner() |
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 |
---|---|---|
@@ -1,8 +1,43 @@ | ||
from django import forms | ||
from django.contrib.auth import get_user_model | ||
|
||
from data.constants import Region | ||
|
||
|
||
User = get_user_model() | ||
|
||
|
||
class SummonerSearchForm(forms.Form): | ||
search = forms.CharField(required=True, widget=forms.TextInput(attrs={"autocomplete": 'off'})) | ||
region = forms.ChoiceField(choices=[(x, x) for x in Region], required=True) | ||
|
||
|
||
class SignupForm(forms.ModelForm): | ||
password_confirmation = forms.CharField() | ||
|
||
class Meta: | ||
model = User | ||
fields = ["email", "password", "password_confirmation"] | ||
widgets = { | ||
"password": forms.PasswordInput(), | ||
"password_confirmation": forms.PasswordInput(), | ||
} | ||
|
||
def clean_password_confirmation(self): | ||
password = self.cleaned_data["password"] | ||
password_confirmation = self.cleaned_data["password_confirmation"] | ||
if password != password_confirmation: | ||
raise forms.ValidationError("password fields did not match") | ||
return password_confirmation | ||
|
||
def clean_email(self): | ||
email = self.cleaned_data["email"].strip() | ||
if User.objects.filter(email__iexact=email).exists(): | ||
raise forms.ValidationError("This email already exists, try logging in.") | ||
return email | ||
|
||
def save(self, commit: bool = True): | ||
self.instance.username = self.instance.email | ||
self.instance.is_active = False | ||
self.instance.set_password(self.cleaned_data["password"]) | ||
return super().save(commit) |
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
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,13 @@ | ||
{% block content %} | ||
<div> | ||
You signed up for an account on hardstuck.club | ||
</div> | ||
|
||
<div> | ||
Please activate your account. | ||
</div> | ||
|
||
<div> | ||
<a href="{{ activation_url }}">{{ activation_url }}</a> | ||
</div> | ||
{% endblock content %} |
Empty file.
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,10 @@ | ||
{% extends "layout/base.html" %} | ||
|
||
{% block content %} | ||
<div class="container mx-auto"> | ||
<h1 class="mx-auto">Account Created</h1> | ||
<div>Please check your email and click the link to activate your account.</div> | ||
|
||
<div>After you activate, you can <a href="{% url 'player:login' %}">Login</a></div> | ||
</div> | ||
{% endblock content %} |
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,25 @@ | ||
{% extends "layout/base.html" %} | ||
|
||
{% block content %} | ||
<div class="container mx-auto"> | ||
<h1 class="mx-auto">Account Activation</h1> | ||
|
||
{% if type == 'success' %} | ||
<div> | ||
You successfully activated your account. | ||
</div> | ||
<div> | ||
Please <a href="{% url 'player:login' %}">log in</a>. | ||
</div> | ||
{% elif type == 'bad_signature' %} | ||
<div> | ||
This link was invalid. Please check your email again. | ||
</div> | ||
{% elif type == 'signature_expired' %} | ||
<div> | ||
This link has expired, please check your email for a new link. | ||
</div> | ||
{% endif %} | ||
|
||
</div> | ||
{% endblock content %} |
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,31 @@ | ||
{% extends "layout/base.html" %} | ||
|
||
{% block header_js %} | ||
{{ block.super }} | ||
<script src="https://www.google.com/recaptcha/enterprise.js?render={{ GOOGLE_RECAPTCHA_KEY }}"></script> | ||
{% endblock header_js %} | ||
|
||
{% block content %} | ||
<div class="container mx-auto"> | ||
<h1 class="mx-auto">Sign Up</h1> | ||
<form id="signup" class="forms" action="" method="POST"> | ||
{% csrf_token %} | ||
{{ form }} | ||
<button | ||
class="g-recaptcha btn btn-success w-full" | ||
data-sitekey="{{ GOOGLE_RECAPTCHA_KEY }}" | ||
data-callback='onSubmit' | ||
data-action='submit' | ||
type="submit" | ||
> | ||
Sign Up | ||
</button> | ||
</form> | ||
</div> | ||
|
||
<script> | ||
function onSubmit(token) { | ||
document.getElementById("signup").submit(); | ||
} | ||
</script> | ||
{% endblock content %} |