src/Extensions/MemberExtension.php
public function isInGracePeriod()
    {
        /** @var Member|MemberExtension $member */
        $member = $this->owner;

        // If MFA is enabled on the member, we're always using it
        if ($member->MFAEnabled) {
            return false;
        }

        /** @var SiteConfig|SiteConfigExtension $config */
        $config = SiteConfig::current_site_config();
        // If MFA is not enforced, we're in an endless grace period
        if ($config->ForceMFA === null) {
            return true;
        }

        // Default the grace start day
        $graceStartDay = ($member->Created > $config->ForceMFA) ? $member->Created : $config->ForceMFA;
        $graceStartDay = new DateTime($graceStartDay);

        $gracePeriodInDays = Config::inst()->get(BootstrapMFAAuthenticator::class, 'grace_period');

        $nowDate = new DateTime(DBDatetime::now()->Format(DBDatetime::ISO_DATE));

        $daysSinceGraceStart = $nowDate->diff($graceStartDay)->days;

        return $daysSinceGraceStart < $gracePeriodInDays;
    }
public function isInGracePeriod()
    {
        /** @var Member|MemberExtension $member */
        $member = $this->owner;

        // If MFA is enabled on the member, we're always using it
        if ($member->MFAEnabled) {
            return false;
        }

        /** @var SiteConfig|SiteConfigExtension $config */
        $config = SiteConfig::current_site_config();
        // If MFA is not enforced, we're in an endless grace period
        if ($config->ForceMFA === null) {
            return true;
        }

        // Default the grace start day
        $graceStartDay = ($member->Created > $config->ForceMFA) ? $member->Created : $config->ForceMFA;
        $graceStartDay = new DateTime($graceStartDay);

        $gracePeriodInDays = Config::inst()->get(BootstrapMFAAuthenticator::class, 'grace_period');

        $nowDate = new DateTime(DBDatetime::now()->Format(DBDatetime::ISO_DATE));

        $daysSinceGraceStart = $nowDate->diff($graceStartDay)->days;

        return $daysSinceGraceStart < $gracePeriodInDays;
    }
public function isInGracePeriod ( ) { /** @var Member|MemberExtension $member */ $ member = $ this -> owner ; // If MFA is enabled on the member, we're always using it if ( $ member -> MFAEnabled ) { return false ; } /** @var SiteConfig|SiteConfigExtension $config */ $ config = SiteConfig :: current_site_config ( ) ; // If MFA is not enforced, we're in an endless grace period if ( $ config -> ForceMFA === null ) { return true ; } // Default the grace start day $ graceStartDay = ( $ member -> Created > $ config -> ForceMFA ) ? $ member -> Created : $ config -> ForceMFA ; $ graceStartDay = new DateTime ( $ graceStartDay ) ; $ gracePeriodInDays = Config :: inst ( ) -> get ( BootstrapMFAAuthenticator :: class , 'grace_period' ) ; $ nowDate = new DateTime ( DBDatetime :: now ( ) -> Format ( DBDatetime :: ISO_DATE ) ) ; $ daysSinceGraceStart = $ nowDate -> diff ( $ graceStartDay ) -> days ; return $ daysSinceGraceStart < $ gracePeriodInDays ; }
Check if a member is in grace period based on Created, date or enforcement
@return bool
@throws \Exception
Check if a member is in grace period based on Created date or enforcement