Merge branch 'dev' of github.com:jumpserver/jumpserver into dev

pull/3781/head
ibuler 2020-03-13 13:57:42 +08:00
commit 3afb8647bd
3 changed files with 10 additions and 3 deletions

View File

@ -596,6 +596,11 @@ class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):
user.save()
user.groups.add(UserGroup.initial())
def can_send_created_mail(self):
if self.email and self.source == self.SOURCE_LOCAL:
return True
return False
@classmethod
def generate_fake(cls, count=100):
from random import seed, choice

View File

@ -17,7 +17,7 @@ def on_user_create(sender, user=None, **kwargs):
logger.debug("Receive user `{}` create signal".format(user.name))
from .utils import send_user_created_mail
logger.info(" - Sending welcome mail ...".format(user.name))
if user.email:
if user.can_send_created_mail():
send_user_created_mail(user)

View File

@ -22,15 +22,15 @@ logger = get_logger(__file__)
@shared_task
def check_password_expired():
users = User.objects.exclude(role=User.ROLE_APP)
users = User.objects.filter(source=User.SOURCE_LOCAL).exclude(role=User.ROLE_APP)
for user in users:
if not user.is_valid:
continue
if not user.password_will_expired:
continue
send_password_expiration_reminder_mail(user)
msg = "The user {} password expires in {} days"
logger.info(msg.format(user, user.password_expired_remain_days))
send_password_expiration_reminder_mail(user)
@shared_task
@ -55,6 +55,8 @@ def check_user_expired():
continue
if not user.will_expired:
continue
msg = "The user {} will expires in {} days"
logger.info(msg.format(user, user.expired_remain_days))
send_user_expiration_reminder_mail(user)