Skip to content

Commit

Permalink
Merge pull request #608 from Ilhasoft/feature/send-email-api
Browse files Browse the repository at this point in the history
Sending welcome to bothub is only sent when the account is created by the rest api
  • Loading branch information
dyohan9 authored Jun 22, 2021
2 parents 10b597d + 1c42081 commit 23f5e18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 6 additions & 4 deletions bothub/api/v2/account/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ class RegisterUserSerializer(serializers.ModelSerializer):
write_only=True, validators=[validate_password], label=_("Password")
)

def create(self, validated_data):
validated_data.pop("recaptcha")
return super().create(validated_data)

class Meta:
model = User
fields = ["email", "name", "nickname", "password", "recaptcha"]
ref_name = None

def create(self, validated_data):
validated_data.pop("recaptcha")
instance = super().create(validated_data)
instance.send_welcome_email()
return instance

@staticmethod
def validate_password(value):
return make_password(value)
Expand Down
6 changes: 0 additions & 6 deletions bothub/authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,3 @@ def get_user_organizations(self):
role=OrganizationAuthorization.LEVEL_NOTHING
).values_list("organization", flat=True)
)


@receiver(models.signals.post_save, sender=User)
def send_welcome_email(instance, created, **kwargs):
if created:
instance.send_welcome_email()
2 changes: 1 addition & 1 deletion bothub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
"OIDC_DRF_AUTH_BACKEND",
default="bothub.authentication.authorization.WeniOIDCAuthenticationBackend",
)
OIDC_RP_SCOPES = env.str("OIDC_RP_SCOPES", default='openid email')
OIDC_RP_SCOPES = env.str("OIDC_RP_SCOPES", default="openid email")


# gRPC Connect Server
Expand Down

0 comments on commit 23f5e18

Please sign in to comment.