diff --git a/taiga/auth/services.py b/taiga/auth/services.py index fe07b1bf..10c4e573 100644 --- a/taiga/auth/services.py +++ b/taiga/auth/services.py @@ -36,7 +36,7 @@ from taiga.users.serializers import UserSerializer from taiga.users.services import get_and_validate_user from .backends import get_token_for_user - +from .signals import user_registered as user_registered_signal def send_public_register_email(user) -> bool: """ @@ -126,6 +126,7 @@ def public_register(username:str, password:str, email:str, full_name:str): raise exc.WrongArguments("User is already register.") # send_public_register_email(user) + user_registered_signal.send(sender=user.__class__, user=user) return user @@ -177,6 +178,7 @@ def private_register_for_new_user(token:str, username:str, email:str, membership = get_membership_by_token(token) membership.user = user membership.save(update_fields=["user"]) + user_registered_signal.send(sender=user.__class__, user=user) return user @@ -202,6 +204,9 @@ def github_register(username:str, email:str, full_name:str, github_id:int, bio:s membership.user = user membership.save(update_fields=["user"]) + if created: + user_registered_signal.send(sender=user.__class__, user=user) + return user diff --git a/taiga/auth/signals.py b/taiga/auth/signals.py new file mode 100644 index 00000000..9c5b9ca0 --- /dev/null +++ b/taiga/auth/signals.py @@ -0,0 +1,20 @@ +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino +# Copyright (C) 2014 David Barragán +# 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 . + +import django.dispatch + + +user_registered = django.dispatch.Signal(providing_args=["user"])