Ignore:
Timestamp:
3 Sep 2025, 07:38:18 (15 months ago)
Author:
Henrik Bettermann
Message:

Implement student password expiration feature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r17769 r18166  
    143143                    self.student_id, granted=True))
    144144        return None
     145
     146    @property
     147    def password_expired(self):
     148        """Can be used to force students to request a new password.
     149        """
     150        try:
     151            days_pw = grok.getSite()['configuration'].days_pw
     152        except TypeError: # in unit tests
     153            return False
     154        if not days_pw:
     155            return False
     156        now = datetime.utcnow()
     157        if self.password_updated is None:
     158            return True
     159        try:
     160            days_ago = getattr(now - self.password_updated, 'days')
     161        except TypeError:
     162            # This happens after reimport of personal_updated because
     163            # Python  can't subtract offset-naive and offset-aware datetimes
     164            return True
     165        if days_ago > days_pw:
     166            return True
     167        return False
    145168
    146169    def writeLogMessage(self, view, message):
Note: See TracChangeset for help on using the changeset viewer.