Private/Polyfony/Security.php
protected static function login() :void {
		
		// look for users with this login
		$account = \Models\Accounts::getFirstEnabledWithLogin(
			Request::post( Config::get('security', 'login') )
		);
		// if the account does not exist/is not found
		if(!$account) {
			// we deny access
			self::refuse('Account does not exist or is disabled'); 
		}
		// if the account has been forced by that ip recently
		if($account->hasFailedLoginAttemptsRecentFrom(self::getSafeRemoteAddress())) {
			// extend the lock on the account
			$account->extendLoginBan();
			// refuse access
			self::refuse('Please wait '.Config::get('security', 'waiting_duration').' seconds before trying again');
		}
		// if the account has expired
		if($account->hasItsValidityExpired()) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse("Your account has expired, it was valid until {$account->get('account_expiration_date')}");	
		}
		// if the posted password doesn't match the account's password
		if(!$account->hasThisPassword(Request::post(Config::get('security', 'password')))) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse('Wrong password');
		}
		// if we failed to open a session
		if(!$account->tryOpeningSession()) {
			// we report that something is wrong
			self::refuse('Your session failed to open, make sure your browser accepts cookies', 500);
		}
		// then session has been opened
		else {
			// log the loggin action
			Logger::info("Account {$account->get('login')} has logged in");
			// put the user inside of us
			self::$_account = $account;
			// set the most basic authentication block as being true/passed
			self::$_granted = true;
			// if we have an url in the session, redirect to it (and remove it)
			!Session::has('previously_requested_url') ?: self::redirectToThePreviouslyRequestedUrl();
		}
		
	}
protected static function login() :void {
		
		// look for users with this login
		$account = \Models\Accounts::getFirstEnabledWithLogin(
			Request::post( Config::get('security', 'login') )
		);
		// if the account does not exist/is not found
		if(!$account) {
			// we deny access
			self::refuse('Account does not exist or is disabled'); 
		}
		// if the account has been forced by that ip recently
		if($account->hasFailedLoginAttemptsRecentFrom(self::getSafeRemoteAddress())) {
			// extend the lock on the account
			$account->extendLoginBan();
			// refuse access
			self::refuse('Please wait '.Config::get('security', 'waiting_duration').' seconds before trying again');
		}
		// if the account has expired
		if($account->hasItsValidityExpired()) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse("Your account has expired, it was valid until {$account->get('account_expiration_date')}");	
		}
		// if the posted password doesn't match the account's password
		if(!$account->hasThisPassword(Request::post(Config::get('security', 'password')))) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse('Wrong password');
		}
		// if we failed to open a session
		if(!$account->tryOpeningSession()) {
			// we report that something is wrong
			self::refuse('Your session failed to open, make sure your browser accepts cookies', 500);
		}
		// then session has been opened
		else {
			// log the loggin action
			Logger::info("Account {$account->get('login')} has logged in");
			// put the user inside of us
			self::$_account = $account;
			// set the most basic authentication block as being true/passed
			self::$_granted = true;
			// if we have an url in the session, redirect to it (and remove it)
			!Session::has('previously_requested_url') ?: self::redirectToThePreviouslyRequestedUrl();
		}
		
	}
protected static function login ( ) : void { // look for users with this login $ account = \ Models \ Accounts :: getFirstEnabledWithLogin ( Request :: post ( Config :: get ( 'security' , 'login' ) ) ) ; // if the account does not exist/is not found if ( ! $ account ) { // we deny access self :: refuse ( 'Account does not exist or is disabled' ) ; } // if the account has been forced by that ip recently if ( $ account -> hasFailedLoginAttemptsRecentFrom ( self :: getSafeRemoteAddress ( ) ) ) { // extend the lock on the account $ account -> extendLoginBan ( ) ; // refuse access self :: refuse ( 'Please wait ' . Config :: get ( 'security' , 'waiting_duration' ) . ' seconds before trying again' ) ; } // if the account has expired if ( $ account -> hasItsValidityExpired ( ) ) { // register that failure $ account -> registerFailedLoginAttemptFrom ( self :: getSafeRemoteAddress ( ) , self :: getSafeUserAgent ( ) ) ; // refuse access self :: refuse ( "Your account has expired, it was valid until {$account->get('account_expiration_date')}" ) ; } // if the posted password doesn't match the account's password if ( ! $ account -> hasThisPassword ( Request :: post ( Config :: get ( 'security' , 'password' ) ) ) ) { // register that failure $ account -> registerFailedLoginAttemptFrom ( self :: getSafeRemoteAddress ( ) , self :: getSafeUserAgent ( ) ) ; // refuse access self :: refuse ( 'Wrong password' ) ; } // if we failed to open a session if ( ! $ account -> tryOpeningSession ( ) ) { // we report that something is wrong self :: refuse ( 'Your session failed to open, make sure your browser accepts cookies' , 500 ) ; } // then session has been opened else { // log the loggin action Logger :: info ( "Account {$account->get('login')} has logged in" ) ; // put the user inside of us self :: $ _account = $ account ; // set the most basic authentication block as being true/passed self :: $ _granted = true ; // if we have an url in the session, redirect to it (and remove it) ! Session :: has ( 'previously_requested_url' ) ? : self :: redirectToThePreviouslyRequestedUrl ( ) ; } }
internal login method that will open a session
internal login method that will open a session