Пример #1
0
 def set_password(self, raw_password):
     super().set_password(raw_password)
     # 没有id,说明是创建用户
     if self.id:
         user_info = self.user_info
         user_info.password_update_date = get_today_date()
         user_info.save()
         user_info.password_history.add_password(self.password)
Пример #2
0
    def handle(self, *args, **options):
        a=1/0
        days = settings.PASSWORD_EXPIRATION_NOTIFICATION.get('days', []) + [0]

        today = get_today_date()
        dates = [today - timedelta(days=(settings.MAX_PASSWORD_AGE - d)) for d in days]

        print(dates)
        base_q = UserInfo.objects.filter(is_active=True, password_never_expire=False)

        for ui in base_q.filter(password_update_date__in=dates[:-1]):
            self.notify(ui, settings.MAX_PASSWORD_AGE - (today - ui.password_update_date).days)

        for ui in base_q.filter(password_update_date__lte=dates[-1]):
            self.notify(ui, 0)
Пример #3
0
 def is_password_expired(self):
     if self.password_never_expire:
         return False
     return (get_today_date() -
             self.password_update_date).days > settings.MAX_PASSWORD_AGE