'Returns whether a password has \'expired\' and should be reset. Note there are two different
expiry policies for staff and students'

@classmethod
def should_user_reset_password_now(cls, user):

    assert user
    if (not settings.FEATURES['ADVANCED_SECURITY']):
        return False
    days_before_password_reset = None
    if user.is_staff:
        if cls.is_staff_forced_password_reset_enabled():
            days_before_password_reset = settings.ADVANCED_SECURITY_CONFIG['MIN_DAYS_FOR_STAFF_ACCOUNTS_PASSWORD_RESETS']
    elif cls.is_student_forced_password_reset_enabled():
        days_before_password_reset = settings.ADVANCED_SECURITY_CONFIG['MIN_DAYS_FOR_STUDENT_ACCOUNTS_PASSWORD_RESETS']
    if days_before_password_reset:
        history = PasswordHistory.objects.filter(user=user).order_by('-time_set')
        time_last_reset = None
        if history:
            time_last_reset = history[0].time_set
        else:
            time_last_reset = user.date_joined
        now = timezone.now()
        delta = (now - time_last_reset)
        return (delta.days >= days_before_password_reset)
    return False
