diff --git a/embark/templates/user/register.html b/embark/templates/user/register.html index 0e7e0893..cd4d4500 100644 --- a/embark/templates/user/register.html +++ b/embark/templates/user/register.html @@ -1,35 +1,16 @@ {% extends "base.html" %} {% load static %} +{% load django_bootstrap5 %} {% block style %}{% endblock style %} {% block title %}EMBArk register{% endblock title %} {% block maincontent %}
- {% if error_message %} - - {% endif %} - {% if success_message %} - - {% endif %} -
-
diff --git a/embark/users/models.py b/embark/users/models.py index 0a701f8a..9e3febc8 100644 --- a/embark/users/models.py +++ b/embark/users/models.py @@ -5,7 +5,7 @@ import enum from django.db import models -from django.contrib.auth.models import User as DjangoUser +from django.contrib.auth.models import AbstractUser from django.conf import settings from lib.choice_enum import ChoiceIntEnum @@ -26,7 +26,7 @@ class Team(models.Model): modified = models.DateTimeField(auto_now=True, help_text='Date time when this entry was modified') -class User(DjangoUser): +class User(AbstractUser): timezone = models.CharField(max_length=32, choices=settings.TIMEZONES, default='UTC') diff --git a/embark/users/views.py b/embark/users/views.py index 1b03c81e..21b85ce6 100644 --- a/embark/users/views.py +++ b/embark/users/views.py @@ -50,7 +50,6 @@ def register(request): user.is_active = False user.save() logger.debug('User created') - # TODO create email + token token = default_token_generator.make_token(user) current_site = get_current_site(request) mail_subject = 'Activate your EMBArk account.' @@ -62,18 +61,22 @@ def register(request): 'token': token, }) - if settings.EMAIL_ACTIVE: + if settings.EMAIL_ACTIVE == True: send_mail(mail_subject, message, 'system@' + settings.DOMAIN, [email]) messages.success(request, 'Registration successful. Please check your email to activate') return redirect(reverse('embark-login')) else: logger.debug("Registered, redirecting to login") - activate_user(user.id, token) + if activate_user(user.id, token): + messages.success(request, 'Registration successful.') + return redirect(reverse('embark-login')) + else: + raise Exception("Activation Error") except builtins.Exception as error: logger.exception('Wide exception in Signup: %s', error) messages.error(request, 'Something went wrong when signing up the user.') - return render(request, 'user/register.html') - return render(request, 'user/register.html') + register_form = SignupForm() + return render(request, 'user/register.html', {'signup_form': register_form}) @require_http_methods(["GET", "POST"])