Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Send confirmation email for newly registered users

Roland Geider81f44dc1940b
diff --git a/wger/core/api/views.py b/wger/core/api/views.py
index 43507ce57..d75e24e4a 100644
--- a/wger/core/api/views.py
+++ b/wger/core/api/views.py
@@ -22,6 +22,7 @@ import logging
from django.contrib.auth.models import User
# Third Party
+from django_email_verification import send_email
from rest_framework import (
status,
viewsets,
@@ -172,6 +173,9 @@ class UserAPIRegistrationViewSet(viewsets.ViewSet):
user.userprofile.save()
token = create_token(user)
+ # Email the user with the activation link
+ send_email(user)
+
return Response(
{
'message': 'api user successfully registered',
diff --git a/wger/core/templates/email_verification/email_body_html.tpl b/wger/core/templates/email_verification/email_body_html.tpl
index f86ab9f86..9e6e2a036 100644
--- a/wger/core/templates/email_verification/email_body_html.tpl
+++ b/wger/core/templates/email_verification/email_body_html.tpl
@@ -8,7 +8,7 @@
<body>
<p>{% blocktranslate with username=user.username %}You are almost there, {{ username }}!{% endblocktranslate %}</p>
<br>
-<p>{% blocktranslate %}Please click <a href="{{ link }}">here</a> to confirm your account{% endblocktranslate %}</p>
+<p>{% blocktranslate %}Please click <a href="{{ link }}">here</a> to confirm your email{% endblocktranslate %}</p>
<p>{% blocktranslate with time=expiry|time:"TIME_FORMAT" %}The token expires on {{ time }}{% endblocktranslate %}</p>
<p><i>{% translate 'the wger Team' %}</i></p>
diff --git a/wger/core/templates/email_verification/email_body_txt.tpl b/wger/core/templates/email_verification/email_body_txt.tpl
index a5f16c162..a1c7b6085 100644
--- a/wger/core/templates/email_verification/email_body_txt.tpl
+++ b/wger/core/templates/email_verification/email_body_txt.tpl
@@ -1,7 +1,7 @@
{% load i18n %}
{% blocktranslate with username=user.username %}You are almost there, {{ username }}!{% endblocktranslate %}
-{% blocktranslate %}Please click the following link to confirm your account: {{ link }}{% endblocktranslate %}
+{% blocktranslate %}Please click the following link to confirm your email: {{ link }}{% endblocktranslate %}
{% blocktranslate with time=expiry|time:"TIME_FORMAT" %}The token expires on {{ time }}{% endblocktranslate %}
diff --git a/wger/core/views/user.py b/wger/core/views/user.py
index 37beb3c16..5e3f4a15f 100644
--- a/wger/core/views/user.py
+++ b/wger/core/views/user.py
@@ -282,9 +282,15 @@ def registration(request):
config.save()
user.userprofile.save()
-
user = authenticate(username=username, password=password)
+
+ # Log the user in
django_login(request, user)
+
+ # Email the user with the activation link
+ send_email(user)
+
+ # Redirect to the dashboard
messages.success(request, _('You were successfully registered'))
return HttpResponseRedirect(reverse('core:dashboard'))
else:
diff --git a/wger/exercises/models/video.py b/wger/exercises/models/video.py
index 8635c121e..ceda61cfa 100644
--- a/wger/exercises/models/video.py
+++ b/wger/exercises/models/video.py
@@ -34,6 +34,7 @@ except ImportError:
from wger.exercises.models import ExerciseBase
from wger.utils.models import AbstractLicenseModel
+
MAX_FILE_SIZE_MB = 100