-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base registration two-step workflow.
- Loading branch information
wlorenzetti
committed
Sep 14, 2023
1 parent
13d1ae4
commit 6c6a02f
Showing
3 changed files
with
47 additions
and
2 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 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,40 @@ | ||
# coding=utf-8 | ||
"""" Usermanage receivers module | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the Mozilla Public License 2.0. | ||
""" | ||
|
||
__author__ = "[email protected]" | ||
__date__ = "2023-09-14" | ||
__copyright__ = "Copyright 2015 - 2023, Gis3w" | ||
__license__ = "MPL 2.0" | ||
|
||
from django.conf import settings | ||
from django.dispatch import receiver | ||
from django_registration.signals import user_registered | ||
from usersmanage.models import Userbackend, USER_BACKEND_DEFAULT, Group as AuthGroup | ||
from usersmanage.configs import G3W_VIEWER1 | ||
import logging | ||
|
||
logger = logging.getLogger('django.request') | ||
|
||
@receiver(user_registered) | ||
def set_user_backend(sender, **kwargs): | ||
""" | ||
Set User-backend on registration | ||
""" | ||
|
||
# Set default g3w-suite backend | ||
Userbackend(user=kwargs['user'], backend=USER_BACKEND_DEFAULT).save() | ||
logger.info(f"Assigned backend {USER_BACKEND_DEFAULT} to registered user {kwargs['user']}") | ||
|
||
# Set default registration role | ||
if hasattr(settings, 'REGISTRATION_MAIN_ROLES'): | ||
for role in settings.REGISTRATION_MAIN_ROLES: | ||
AuthGroup.objects.get(name=role).user_set.add(kwargs["user"]) | ||
else: | ||
|
||
# By default, add user to Viewer Level 1 group | ||
AuthGroup.objects.get(name=G3W_VIEWER1).user_set.add(kwargs['user']) | ||
|
4 changes: 2 additions & 2 deletions
4
g3w-admin/usersmanage/templates/django_registration/activation_email_body.txt
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,6 +1,6 @@ | ||
|
||
Dear {{user.username}}, | ||
|
||
please got to the following link or copy it an pate in you browser to activate your account and validate your email. | ||
please got to the following link or copy it and paste in you browser to activate your account and validate your email. | ||
|
||
<a href="{% url 'django_registration_activate' activation_key %}">{% url 'django_registration_activate' activation_key %}</a> | ||
{% url 'django_registration_activate' activation_key %} |