nodesource / ncm-cli

Command-line tool for NodeSource Certified Modules 2.0
Other
19 stars 13 forks source link

We need an error state for whitelist queries that are associated with expired orgs #160

Closed mnedelko closed 5 years ago

mnedelko commented 5 years ago

When using 'ncm whitelist --list' the following error occurs:

image

I am:

Fishrock123 commented 5 years ago

The offending lines are here: https://github.com/nodesource/ncm-cli/blob/e2783bc06618a37bce7c8771536ab8ec8422bc79/commands/whitelist.js#L58-L77

I guess whatever login you have doesn't have a policy attached... probably because it was set to non-org 'personal' which wouldn't have this data? I think? Guess we should bail out correctly and tell people that they need a valid org to use the whitelist.

mnedelko commented 5 years ago

'probably because it was set to non-org 'personal' which wouldn't have this data'

But I was logged into the NodeSource organization. Not personal.

juliangruber commented 5 years ago

@mnedelko can you invite @Fishrock123 and me to your NodeSourceTestOrg? I tried to reproduce this and neither the personal, nor the test or NodeSource org showed this behavior.

juliangruber commented 5 years ago

@Fishrock123 I do wonder why his org doesn't have a policy. Could it be this org was created before policies?

mnedelko commented 5 years ago

@juliangruber I believe you are already in the org by the looks of it. That said, I am realizing that this org should be called NodeSource org not NodeSourceTestorg. Could this be the issue? Accounts.nodesource.org just calls it NodeSource.

image

I am looking in via mike.nedelko@nodesource.com and the only options I am provided with are (1) Personal and (2)NodeSourceTestOrg:

image

juliangruber commented 5 years ago

this is interesting, then I think it's not the same org. Did you log in via google auth both times, or did you use email/password for one?

brycebaril commented 5 years ago

Looks like the test org uses your personal Gmail account, not your corp Google account.

accounts=> select * from organizations where name like 'Node%';
                org_id                |          name           |            created            | require_domain | stripe_customer_id 
--------------------------------------+-------------------------+-------------------------------+----------------+--------------------
 be1bfa20-6279-4a86-89cc-6e5aba122360 | NodeSource              | 2018-08-30 10:30:19.470622+00 | f              | 
 7c102e44-216d-485d-9b78-45567c366477 | NodeSource              | 2018-08-30 22:33:31.626561+00 | f              | 
 fd66a830-1095-4711-8a77-642c50d64a74 | NodeSource Training Org | 2018-10-04 21:49:03.336747+00 | f              | 
 ef920a16-6412-47a2-a17b-8662caf093d3 | NodesourceTestOrg       | 2018-11-10 00:00:40.306763+00 | f              | 
 83074b73-fea7-44f2-a4c9-1d2941f51ab0 | NodeSourceTest          | 2019-04-16 07:48:22.316815+00 | f              | 
 53577361-015f-461d-abbd-5ce36ad00c5f | NodeSourceTestMike      | 2019-04-19 21:25:17.990878+00 | f              | 
(6 rows)

accounts=> select * from organization_user_roles where org_id = 'ef920a16-6412-47a2-a17b-8662caf093d3';
                org_id                |               user_id                | role  | active |             added             
--------------------------------------+--------------------------------------+-------+--------+-------------------------------
 ef920a16-6412-47a2-a17b-8662caf093d3 | 1d3bfad1-107f-4db5-ae1c-4cc49a27de34 | owner | t      | 2018-11-10 00:00:40.306763+00
(1 row)

accounts=> select * from users where user_id = '1d3bfad1-107f-4db5-ae1c-4cc49a27de34';
               user_id                |       email        | phone |     real_name      | company | username |            created            | verified |          last_login           | login_count |       terms_accepted       | trial_state 
--------------------------------------+--------------------+-------+--------------------+---------+----------+-------------------------------+----------+-------------------------------+-------------+----------------------------+-------------
 1d3bfad1-107f-4db5-ae1c-4cc49a27de34 | mnedelko@gmail.com |       | mnedelko@gmail.com |         |          | 2018-11-09 23:23:24.829271+00 | t        | 2019-06-24 19:19:20.500424+00 |          24 | 2018-11-09 23:24:18.245+00 | used
(1 row)

accounts=> 
mnedelko commented 5 years ago

I figured it out.

So when signing in with signing -g I logged in via github. That meant my private email address. This was associated with a NodeSourceTestOrg for which a trial/ org had expired.

We should probably provide an error state for orgs whose trials have expired, but at least this isn’t badly broken.