Getting the ACTUAL current user

49 views
Skip to first unread message

Andrew Apell

unread,
Apr 17, 2020, 1:15:34 AM4/17/20
to google-apps-sc...@googlegroups.com
Like most of us here, I have a spreadsheet based add-on that is published in the G Suite Marketplace.
As a business decision, permissions are granted to a single user, with options to add multiple users on a different subscription plan.

I have one nagging issue though:
I have noticed that, if a user is logged into 2 different accounts on the same spreadsheet, and the "default account" is authorised to use the add-on but the secondary account isn't, the latter will still be able to comfortably use the add-on without issue. This is happening despite the fact that I have code to prevent use of the add-on on spreadsheets that are shared amongst multiple users.

Is there a way of determining the actual current user regardless of how many are logged in at that time? Or, if any of you gurus have other tips on how to solve this problem, do you mind sharing it?
I know that there are other ways of gaming the system but my effort here is to make it as hard as possible.

EDIT:
I see that one can prevent files in a Drive folder from being shared. Is there a spreadsheet specific version of this method?

Andrew Roberts

unread,
Apr 17, 2020, 6:14:27 AM4/17/20
to google-apps-sc...@googlegroups.com
Multiple accounts has been a bug-bear for a long time! 

The GSheet URL does show how many people are logged into on that device:

This is the URL of a GSheet from my default account:


And this is it from another account on my device - note the number 4 in the middle (I am logged into 7 different accounts):


I don't know if it is possible to use that somehow??

On Fri, 17 Apr 2020 at 06:15, Andrew Apell <chis...@gmail.com> wrote:
Like most of us here, I have a spreadsheet based add-on that is published in the G Suite Marketplace.
As a business decision, permissions are granted to a single user, with options to add multiple users on a different subscription plan.

I have one nagging issue though:
I have noticed that, if a user is logged into 2 different accounts on the same spreadsheet, and the "default account" is authorised to use the add-on but the secondary account isn't, the latter will still be able to comfortably use the add-on without issue. This is happening despite the fact that I have code to prevent use of the add-on on spreadsheets that are shared amongst multiple users.

Is there a way of determining the actual current user regardless of how many are logged in at that time? Or, if any of you gurus have other tips on how to solve this problem, do you mind sharing it?
I know that there are other ways of gaming the system but my effort here is to make it as hard as possible.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/73b69cc6-b2aa-4e56-88e3-c690d9fd316d%40googlegroups.com.

Andrew Apell

unread,
Apr 17, 2020, 6:20:15 AM4/17/20
to Google Apps Script Community
I saw this too but could not figure out a way to actually make it work... still looking
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Andrew Roberts

unread,
Apr 17, 2020, 7:01:34 AM4/17/20
to google-apps-sc...@googlegroups.com
Keep us posted - it is an interesting topic.

There may be workarounds in the comment sections of the various "multi-users" issues in the issue tracker.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/9e615c2b-7d76-4b3d-a313-9b1f1ca2d277%40googlegroups.com.

Andrew Apell

unread,
Apr 17, 2020, 7:06:30 AM4/17/20
to Google Apps Script Community
I saw one post on Stack Overflow which recommends forcefully removing other all editors except the spreadsheet owner.
It works but I think we can all agree that doing this will take away from the overall user experience.
I will post back if I find something that works...


On Friday, 17 April 2020 14:01:34 UTC+3, andrew wrote:
Keep us posted - it is an interesting topic.

There may be workarounds in the comment sections of the various "multi-users" issues in the issue tracker.

On Fri, 17 Apr 2020 at 11:20, Andrew Apell <chis...@gmail.com> wrote:
I saw this too but could not figure out a way to actually make it work... still looking

On Friday, 17 April 2020 13:14:27 UTC+3, andrew wrote:
Multiple accounts has been a bug-bear for a long time! 

The GSheet URL does show how many people are logged into on that device:

This is the URL of a GSheet from my default account:


And this is it from another account on my device - note the number 4 in the middle (I am logged into 7 different accounts):


I don't know if it is possible to use that somehow??

On Fri, 17 Apr 2020 at 06:15, Andrew Apell <chis...@gmail.com> wrote:
Like most of us here, I have a spreadsheet based add-on that is published in the G Suite Marketplace.
As a business decision, permissions are granted to a single user, with options to add multiple users on a different subscription plan.

I have one nagging issue though:
I have noticed that, if a user is logged into 2 different accounts on the same spreadsheet, and the "default account" is authorised to use the add-on but the secondary account isn't, the latter will still be able to comfortably use the add-on without issue. This is happening despite the fact that I have code to prevent use of the add-on on spreadsheets that are shared amongst multiple users.

Is there a way of determining the actual current user regardless of how many are logged in at that time? Or, if any of you gurus have other tips on how to solve this problem, do you mind sharing it?
I know that there are other ways of gaming the system but my effort here is to make it as hard as possible.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Andrew Apell

unread,
Apr 17, 2020, 12:42:21 PM4/17/20
to Google Apps Script Community
Promising lead:
Compare your database with the list of editors. Whichever editor is not found approved in the database, eject them from the list of editors via the getEditors().splice(...) method.
I'm running test now...

CBM Services

unread,
Apr 17, 2020, 1:05:47 PM4/17/20
to google-apps-sc...@googlegroups.com
Just a side note on this, even Goggle has problems with this. The Android Google Drive can't figure out how to allow one file to be edited when multiple users signed in and only one of them has edit capability.

From: Andrew Apell
Sent: ‎2020-‎04-‎17 9:42 AM
To: Google Apps Script Community
Subject: Re: [Apps-Script] Getting the ACTUAL current user

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d0721b1a-4d1a-4af5-9ff7-5f0f72fdc11d%40googlegroups.com.

Andrew Apell

unread,
Apr 19, 2020, 2:17:16 PM4/19/20
to Google Apps Script Community
Sure, I'm aware of Google's issues.
As I mentioned in my original post, all that needs to happen is for one authorised user to login first, then all subsequent users will ride on the first user's authorisation.
This, of course, is  loophole that can be easily exploited (deliberately or otherwise) by our clients.
My solution is simple:
Compare the list of editors to the the list of authorised users. If the 2 lists don't match, stop the add-on procedure from completing.
I hope this helps someone.
Reply all
Reply to author
Forward
0 new messages