/** * Application Turn-Key. * * @notes Application Turn-key * A destination requested before authenticating relays * user to desired URL/destination (this by-passes Panel). * * Sometimes a user has requested a destination before * authenticating on the system. This checks to see if * a destination was set and will relay to the URL once * authentication has been completed. * * To use prior to authenticating, assign the full * application URL to $session->setPassport('destination_relay'). * Once authenticated, the /Login/index.php will relay * to the destination. * * @return bool */ public function runApplicationTurnKey() : bool { $session = ServiceRequestContainer::perform()->Session; if (!ServiceRequestContainer::perform()->Passport->has('token')) { $session->setPassport('destination_relay', $this->getProperty('relRootApp')); $this->requestRoute($this->getProperty('redirectLogout') . '/php-token-missing/'); } else { $this->turnKeyValidate($session, $this->dbh->isSessionTokenAvailable($session->getPassport('token'))->getRecords()); } return true; }
/** * Validate Username. * * -- Must start with a letter * -- Uppercase and lowercase letters accepted * -- 2-8 characters in length * -- Letters, numbers, underscores, dots, and dashes only * -- * -- An email is a preferred username * * @param string $userName The user provided username * * @return bool */ public function validateUsername(string $userName = null) : bool { if (null === $userName) { $this->dbh->insertiNetRecordLog($userName, '-- Login Error: Username not provided or bad parameter.'); return false; } if (!(bool) preg_match('/^[a-z][a-z\\d_.-]*$/i', trim(mb_substr(trim(strtolower($userName)), 0, 64, 'UTF-8')))) { $this->dbh->insertiNetRecordLog($userName, '-- Login Error: Username did not meet login requirements for AD Username.'); return false; } return true; }
/** * Build user passport. * * @param string $email The system provided email * * @return SessionInterface The current instance * * @api */ public function createUserPassport(string $email) : SessionInterface { $data = $this->dbh->getUserAccountProfile($email)->getRecord(); if (1 !== $data['record_count']) { $this->dbh->insertiNetRecordLog($email, '-- Error: DB says user does not exist'); $this->requestRoute($this->getProperty('redirectLogout') . '/problem_creating_user_passport/'); } $this->isIntranetAccessEnabledForUser($data, $email); /* Build passport. */ $this->loadPassport($this->getPassportItems($data, 'createUserPassport'))->setDatabaseSession(); $this->sessionManager->get('passport/destination_relay') ?: $this->setPassport('destination_relay', $this->getProperty('redirectPanel') . '/'); return $this; }
/** * Set the current PHP system version. * * @return ConfigurationInterface The current instance */ protected function setMySQLVersion(DatabaseInterface $database) : ConfigurationInterface { return $this->set('mysql_version', $database->getMySQLVersion()); }