site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Analytics setup missing verification of user's access to existing tag found through front end request

Open lucymtc opened this issue 7 years ago • 10 comments

Bug Description

During analytics setup flow when existing tag is found the plugin only verifies the user's access to the property when found through wp_head hook and not through the front end request.

The user should be blocked from continuing Analytics configuration if hasn't got access to the property found.

Steps to reproduce

  1. Add Analytics tag in the theme header.php, make sure you don't have access to the property.
  2. Go to Settings > Connect More Services
  3. Click on Analytics setup link.
  4. User gets warned an existing tag was found but no warning about restricted access and not blocked from configuring Analytics.

Screenshots

Screen Shot 2019-07-03 at 14 56 53

Expected:

Screen Shot 2019-07-03 at 15 03 00

Additional Context

  • PHP Version: 7.1
  • OS: mac
  • Browser: chrome (all)
  • Plugin Version: Developer beta
  • Device: macbook

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Users who don't have access to an already existing property on the site should see a notification why that's the case and possible next steps.
  • Do not show drop-downs if the user can't in fact select anything.

Implementation Brief

Note: Work done previously on other issue and then split into new issue with opened PR https://github.com/google/site-kit-wp/pull/310

Add new datapoint tag-permission to make request in the case existing tag is found https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/analytics/setup.js#L95 On the request to tag-permission check if user has access to the property and return response or return WP_Error with expected message in the case the user has no permissions.

Changelog entry

  • Improve user access verification when encountering existing Analytics tags.

lucymtc avatar Jul 03 '19 13:07 lucymtc

@ThierryA @marrrmarrr adding this to the definition board and noting that we already have a PR ready for this on.

bjackson27 avatar Jul 11 '19 13:07 bjackson27

@bjackson27 Which PR are you referring to?

felixarntz avatar Jul 17 '19 14:07 felixarntz

@felixarntz the opened PR https://github.com/google/site-kit-wp/pull/310

lucymtc avatar Jul 18 '19 13:07 lucymtc

Implementation brief looks good. Would generally be great to have more detail on how access is checked, but since there's already a PR that clarifies that, it's okay this time.

felixarntz avatar Jul 18 '19 15:07 felixarntz

This is what I see when I output a tracking code in wp_head for a property that my user does not have access to:

image

@lucymtc This seems to be consistent with the acceptance criteria; has this been already fixed as a byproduct of another issue?

Using develop @ 5ba7ab9

aaemnnosttv avatar Jul 22 '19 11:07 aaemnnosttv

@aaemnnosttv this issue is for when tag is hardcoded in the theme and not added through wp_head

lucymtc avatar Jul 22 '19 11:07 lucymtc

@aaemnnosttv @swissspidy @lucymtc let's make sure Changelog entry is added on this issue.

ThierryA avatar Jul 23 '19 14:07 ThierryA

Added a suggested changelog entry to the the issue:

Improved user access verification when encountering existing Analytics tags.

swissspidy avatar Jul 26 '19 08:07 swissspidy

QA approved!

felixarntz avatar Jul 30 '19 12:07 felixarntz

LGTM

marrrmarrr avatar Jul 31 '19 08:07 marrrmarrr