Example #1
0
 /**
  * Logs the authentication activity against the user.
  *
  * @param Request $request the OpenID request
  * @param array $consents if not `null`, saves the consents
  */
 protected function logActivity($request, $consents = NULL)
 {
     $store = StoreManager::instance();
     $auth = AuthManager::instance();
     $user = $auth->getUser();
     $realm = $request->getRealm();
     $cid = RelyingParty::buildID($realm);
     $relying_party = $this->loadRelyingParty($realm, true);
     $now = time();
     $activity = array('type' => 'app', 'id' => $realm, 'time' => $now);
     if ($this->f3->exists('IP')) {
         $activity['remote'] = $this->f3->get('IP');
     }
     $user->addActivity($cid, $activity);
     if (isset($user->clients[$cid])) {
         $prefs = $user->clients[$cid];
     } else {
         $prefs = array('openid' => array('version' => $request->getVersion()), 'store_id' => $relying_party->getStoreID(), 'display_name' => $relying_party->getDisplayName(), 'display_html' => $relying_party->getDisplayHTML(), 'first_time' => $now, 'consents' => array());
     }
     $prefs['last_time'] = $now;
     if ($consents != null) {
         $prefs['consents'] = $consents;
     }
     $user->clients[$cid] = $prefs;
     $store->saveUser($user);
 }