forked from Hostea/dashboard
feat: registration with email confirmation flows
parent
583a65bc18
commit
453b115485
@ -0,0 +1,43 @@
|
||||
# Generated by Django 4.0.3 on 2022-06-10 16:09
|
||||
|
||||
import accounts.utils
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="AccountConfirmChallenge",
|
||||
fields=[
|
||||
(
|
||||
"challenge_text",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default=accounts.utils.gen_secret,
|
||||
editable=False,
|
||||
max_length=32,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="Challenge text",
|
||||
),
|
||||
),
|
||||
(
|
||||
"owned_by",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 4.0.3 on 2022-06-10 16:28
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("accounts", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="accountconfirmchallenge",
|
||||
name="owned_by",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
]
|
@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.0.3 on 2022-06-10 16:28
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("accounts", "0002_alter_accountconfirmchallenge_owned_by"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="accountconfirmchallenge",
|
||||
name="owned_by",
|
||||
field=models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
|
||||
),
|
||||
),
|
||||
]
|
@ -0,0 +1,38 @@
|
||||
# Generated by Django 4.0.3 on 2022-06-10 16:44
|
||||
|
||||
import accounts.utils
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("accounts", "0003_alter_accountconfirmchallenge_owned_by"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="accountconfirmchallenge",
|
||||
name="public_ref",
|
||||
field=models.CharField(
|
||||
default=accounts.utils.gen_secret,
|
||||
editable=False,
|
||||
max_length=32,
|
||||
unique=True,
|
||||
verbose_name="Public referece to challenge text",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="accountconfirmchallenge",
|
||||
name="challenge_text",
|
||||
field=models.CharField(
|
||||
default=accounts.utils.gen_secret,
|
||||
editable=False,
|
||||
max_length=32,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
verbose_name="Challenge text",
|
||||
),
|
||||
),
|
||||
]
|
@ -1,3 +1,50 @@
|
||||
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.http import urlencode
|
||||
from django.urls import reverse
|
||||
|
||||
from .utils import gen_secret
|
||||
|
||||
|
||||
class AccountConfirmChallenge(models.Model):
|
||||
owned_by = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
public_ref = models.CharField(
|
||||
"Public referece to challenge text",
|
||||
unique=True,
|
||||
max_length=32,
|
||||
default=gen_secret,
|
||||
editable=False,
|
||||
)
|
||||
|
||||
challenge_text = models.CharField(
|
||||
"Challenge text",
|
||||
unique=True,
|
||||
max_length=32,
|
||||
default=gen_secret,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.challenge_text}"
|
||||
|
||||
# Create your models here.
|
||||
def verification_link(self):
|
||||
"""
|
||||
Get verification link
|
||||
"""
|
||||
return reverse("accounts.verify", args=(self.challenge_text,))
|
||||
|
Loading…
Reference in New Issue