Ejemplo n.º 1
0
 /**
  * Retrieves a token for use in registering this Known site with a hub. Tokens last for 10 minutes.
  * @return string
  */
 function getRegistrationToken()
 {
     if (empty(site()->config->hub_settings)) {
         site()->config->hub_settings = array();
     }
     if (!empty(site()->config->hub_settings['registration_token'])) {
         if (!empty(site()->config->hub_settings['registration_token_expiry'])) {
             if (site()->config->hub_settings['registration_token_expiry'] > time() - 600) {
                 return site()->config->hub_settings['registration_token'];
             }
         }
     }
     $token_generator = new TokenProvider();
     $token = $token_generator->generateToken(32);
     $config = site()->config;
     $config->hub_settings['registration_token'] = bin2hex($token);
     $config->hub_settings['registration_token_expiry'] = time();
     $config->save();
     site()->config = $config;
     return site()->config->hub_settings['registration_token'];
 }
Ejemplo n.º 2
0
 /**
  * Retrieves a token for use in registering this Known site with a hub. Tokens last for 10 minutes.
  * @return string
  */
 function getRegistrationToken()
 {
     if (empty(\Idno\Core\Idno::site()->config->hub_settings) || !is_array(\Idno\Core\Idno::site()->config->hub_settings)) {
         \Idno\Core\Idno::site()->config->hub_settings = array();
     }
     if (!empty(\Idno\Core\Idno::site()->config->hub_settings['registration_token'])) {
         if (!empty(\Idno\Core\Idno::site()->config->hub_settings['registration_token_expiry'])) {
             if (\Idno\Core\Idno::site()->config->hub_settings['registration_token_expiry'] > time() - 600) {
                 return \Idno\Core\Idno::site()->config->hub_settings['registration_token'];
             }
         }
     }
     $token_generator = new TokenProvider();
     $token = $token_generator->generateToken(32);
     $hextoken = (string) bin2hex($token);
     \Idno\Core\Idno::site()->config->hub_settings = array('registration_token' => (string) bin2hex($token), 'registration_token_expiry' => time());
     \Idno\Core\Idno::site()->config->save();
     return \Idno\Core\Idno::site()->config->hub_settings['registration_token'];
 }