mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
Send welcome email when user created by login with proton (#1115)
* Send welcome email when user created by login with proton * Add dedicated test to user.created_by_partner
This commit is contained in:
parent
5fa41d6ccf
commit
dd0598a4dd
@ -9,7 +9,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from app import config
|
from app import config
|
||||||
from app.db import Session
|
from app.db import Session
|
||||||
from app.email_utils import send_email_at_most_times, render
|
from app.email_utils import send_email_at_most_times, send_welcome_email, render
|
||||||
from app.errors import AccountAlreadyLinkedToAnotherPartnerException
|
from app.errors import AccountAlreadyLinkedToAnotherPartnerException
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import (
|
from app.models import (
|
||||||
@ -182,6 +182,9 @@ class NewUserStrategy(ClientMergeStrategy):
|
|||||||
)
|
)
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
|
||||||
|
if not new_user.created_by_partner:
|
||||||
|
send_welcome_email(new_user)
|
||||||
|
|
||||||
agent.record_custom_event("PartnerUserCreation", {"partner": self.partner.name})
|
agent.record_custom_event("PartnerUserCreation", {"partner": self.partner.name})
|
||||||
|
|
||||||
return LinkResult(
|
return LinkResult(
|
||||||
|
@ -525,6 +525,12 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
|||||||
- CustomDomain.filter_by(user_id=self.id, is_sl_subdomain=True).count(),
|
- CustomDomain.filter_by(user_id=self.id, is_sl_subdomain=True).count(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_by_partner(self):
|
||||||
|
return User.FLAG_CREATED_FROM_PARTNER == (
|
||||||
|
self.flags & User.FLAG_CREATED_FROM_PARTNER
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def subdomain_is_available():
|
def subdomain_is_available():
|
||||||
return SLDomain.filter_by(can_use_subdomain=True).count() > 0
|
return SLDomain.filter_by(can_use_subdomain=True).count() > 0
|
||||||
|
@ -21,3 +21,11 @@ def test_create_from_partner(flask_client):
|
|||||||
assert job is not None
|
assert job is not None
|
||||||
assert job.name == config.JOB_SEND_PROTON_WELCOME_1
|
assert job.name == config.JOB_SEND_PROTON_WELCOME_1
|
||||||
assert job.payload.get("user_id") == user.id
|
assert job.payload.get("user_id") == user.id
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_created_by_partner(flask_client):
|
||||||
|
user_from_partner = User.create(email=random_email(), from_partner=True)
|
||||||
|
assert user_from_partner.created_by_partner is True
|
||||||
|
|
||||||
|
regular_user = User.create(email=random_email())
|
||||||
|
assert regular_user.created_by_partner is False
|
||||||
|
Loading…
Reference in New Issue
Block a user