Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparklines do not show when dashboard is included from iframe #3915

Closed
anonymous-matomo-user opened this issue Apr 26, 2013 · 3 comments
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@anonymous-matomo-user
Copy link

When the dashboard is included within an iframe the little sparkline graphs do not show because the token_auth GET parameter is not included in the image link. I can fix this by adding the token_auth parameter to the getUrlSparkline call:

$view->urlSparklineNbVisits = $this->getUrlSparkline( 'getEvolutionGraph', array('token_auth' => Piwik::getCurrentUserTokenAuth(), 'columns' => $view->displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits')));

@mattab
Copy link
Member

mattab commented Apr 28, 2013

Good point, I guess the main controller should set the auth cookie for token_auth'ed request, then the Sparklines would have auth from the cookie. Not sure why it is not working already this way, there might be a reason...

@pebosi
Copy link
Contributor

pebosi commented May 27, 2013

Same problem here.

Tried with this:

    static public function reloadAuthUsingTokenAuth($request = null)
    {
        // if a token_auth is specified in the API request, we load the right permissions
        $token_auth = Piwik_Common::getRequestVar('token_auth', '', 'string', $request);
        if ($token_auth) {
            Piwik_PostEvent('API.Request.authenticate', $token_auth);

############## ADDED
            $authCookieName = Piwik_Config::getInstance()->General['login_cookie_name'];
            $authCookieExpiry = 0;
            $authCookiePath = Piwik_Config::getInstance()->General['login_cookie_path'];
            $cookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath);
            $auth = Zend_Registry::get('auth');

            $login = Piwik_FetchOne(
                'SELECT login
                FROM ' . Piwik_Common::prefixTable('user') . '
                                                                WHERE token_auth = ?',
                array($token_auth)
            );

            $cookie->set('login', $login);
            $cookie->set('token_auth', $auth->getHashTokenAuth($login, $token_auth));
            $cookie->setSecure(Piwik::isHttps());
            $cookie->setHttpOnly(true);
            $cookie->save();
############## ADDED END

            Zend_Registry::get('access')->reloadAccess();
            Piwik::raiseMemoryLimitIfNecessary();
        }
    }

But is this safe or is there a better place?

@mattab
Copy link
Member

mattab commented Jan 10, 2014

This was fixed sometimes as it's working for me!

@anonymous-matomo-user anonymous-matomo-user added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

3 participants