コード例 #1
0
 /**
  * This action handles Persona login page.
  *
  * If this action is reached through a POST request, assertion from Persona
  * is verificated and user connected if all is ok.
  *
  * Parameter is:
  *   - assertion (default: false)
  *
  * @todo: Persona system should be moved to a plugin
  */
 public function personaLoginAction()
 {
     $this->view->res = false;
     if (Minz_Request::isPost()) {
         $this->view->_useLayout(false);
         $assert = Minz_Request::param('assertion');
         $url = 'https://verifier.login.persona.org/verify';
         $params = 'assertion=' . $assert . '&audience=' . urlencode(Minz_Url::display(null, 'php', true));
         $ch = curl_init();
         $options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => 2, CURLOPT_POSTFIELDS => $params);
         curl_setopt_array($ch, $options);
         $result = curl_exec($ch);
         curl_close($ch);
         $res = json_decode($result, true);
         $login_ok = false;
         $reason = '';
         if ($res['status'] === 'okay') {
             $email = filter_var($res['email'], FILTER_VALIDATE_EMAIL);
             if ($email != '') {
                 $persona_file = DATA_PATH . '/persona/' . $email . '.txt';
                 if (($current_user = @file_get_contents($persona_file)) !== false) {
                     $current_user = trim($current_user);
                     $conf = get_user_configuration($current_user);
                     if (!is_null($conf)) {
                         $login_ok = strcasecmp($email, $conf->mail_login) === 0;
                     } else {
                         $reason = 'Invalid configuration for user ' . '[' . $current_user . ']';
                     }
                 }
             } else {
                 $reason = 'Invalid email format [' . $res['email'] . ']';
             }
         } else {
             $reason = $res['reason'];
         }
         if ($login_ok) {
             Minz_Session::_param('currentUser', $current_user);
             Minz_Session::_param('mail', $email);
             FreshRSS_Auth::giveAccess();
             invalidateHttpCache();
         } else {
             Minz_Log::warning($reason);
             $res = array();
             $res['status'] = 'failure';
             $res['reason'] = _t('feedback.auth.login.invalid');
         }
         header('Content-Type: application/json; charset=UTF-8');
         $this->view->res = $res;
     }
 }
コード例 #2
0
            fwrite(STDOUT, 'FreshRSS skip inactive user ' . $user . "\n");
            //Unbuffered
        }
        continue;
    }
    Minz_Log::notice('FreshRSS actualize ' . $user, $log_file);
    if (defined('STDOUT')) {
        fwrite(STDOUT, 'Actualize ' . $user . "...\n");
        //Unbuffered
    }
    echo $user, ' ';
    //Buffered
    Minz_Session::_param('currentUser', $user);
    new Minz_ModelPdo($user);
    //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init
    FreshRSS_Auth::giveAccess();
    $app->init();
    $app->run();
    if (!invalidateHttpCache()) {
        Minz_Log::notice('FreshRSS write access problem in ' . join_path(USERS_PATH, $user, 'log.txt'), $log_file);
        if (defined('STDERR')) {
            fwrite(STDERR, 'Write access problem in ' . join_path(USERS_PATH, $user, 'log.txt') . "\n");
        }
    }
}
Minz_Log::notice('FreshRSS actualize done.', $log_file);
if (defined('STDOUT')) {
    fwrite(STDOUT, 'Done.' . "\n");
    $end_date = date_create('now');
    $duration = date_diff($end_date, $begin_date);
    fwrite(STDOUT, 'Ending feed actualization at ' . $end_date->format('c') . "\n");