Esempio n. 1
0
 private function initAuth()
 {
     FreshRSS_Auth::init();
     if (Minz_Request::isPost() && !is_referer_from_same_domain()) {
         // Basic protection against XSRF attacks
         FreshRSS_Auth::removeAccess();
         $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
         Minz_Error::error(403, array('error' => array(_t('access_denied'), ' [HTTP_REFERER=' . htmlspecialchars($http_referer) . ']')));
     }
 }
Esempio n. 2
0
 private function initAuth()
 {
     FreshRSS_Auth::init();
     if (Minz_Request::isPost() && !is_referer_from_same_domain()) {
         // Basic protection against XSRF attacks
         FreshRSS_Auth::removeAccess();
         $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
         Minz_Translate::init('en');
         //TODO: Better choice of fallback language
         Minz_Error::error(403, array('error' => array(_t('feedback.access.denied'), ' [HTTP_REFERER=' . htmlspecialchars($http_referer) . ']')));
     }
 }
Esempio n. 3
0
 /**
  * This action removes all accesses of the current user.
  */
 public function logoutAction()
 {
     invalidateHttpCache();
     FreshRSS_Auth::removeAccess();
     Minz_Request::good(_t('feedback.auth.logout.success'), array('c' => 'index', 'a' => 'index'));
 }
Esempio n. 4
0
 /**
  * This action delete an existing user.
  *
  * Request parameter is:
  *   - username
  *
  * @todo clean up this method. Idea: create a User->clean() method.
  */
 public function deleteAction()
 {
     $username = Minz_Request::param('username');
     $redirect_url = urldecode(Minz_Request::param('r', false, true));
     if (!$redirect_url) {
         $redirect_url = array('c' => 'user', 'a' => 'manage');
     }
     $self_deletion = Minz_Session::param('currentUser', '_') === $username;
     if (Minz_Request::isPost() && (FreshRSS_Auth::hasAccess('admin') || $self_deletion)) {
         $db = FreshRSS_Context::$system_conf->db;
         require_once APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php';
         $ok = ctype_alnum($username);
         $user_data = join_path(DATA_PATH, 'users', $username);
         if ($ok) {
             $default_user = FreshRSS_Context::$system_conf->default_user;
             $ok &= strcasecmp($username, $default_user) !== 0;
             //It is forbidden to delete the default user
         }
         if ($ok && $self_deletion) {
             // We check the password if it's a self-destruction
             $nonce = Minz_Session::param('nonce');
             $challenge = Minz_Request::param('challenge', '');
             $ok &= FreshRSS_FormAuth::checkCredentials($username, FreshRSS_Context::$user_conf->passwordHash, $nonce, $challenge);
         }
         if ($ok) {
             $ok &= is_dir($user_data);
         }
         if ($ok) {
             $userDAO = new FreshRSS_UserDAO();
             $ok &= $userDAO->deleteUser($username);
             $ok &= recursive_unlink($user_data);
             //TODO: delete Persona file
         }
         if ($ok && $self_deletion) {
             FreshRSS_Auth::removeAccess();
             $redirect_url = array('c' => 'index', 'a' => 'index');
         }
         invalidateHttpCache();
         $notif = array('type' => $ok ? 'good' : 'bad', 'content' => _t('feedback.user.deleted' . (!$ok ? '.error' : ''), $username));
         Minz_Session::_param('notification', $notif);
     }
     Minz_Request::forward($redirect_url, true);
 }