Skip to content

Commit

Permalink
Show a clear warning to team admins incorrectly logging into the tool
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Feb 14, 2024
1 parent 0235384 commit 02c8d47
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@fortawesome/free-regular-svg-icons": "^5.12.1",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/react-fontawesome": "^0.1.8",
"@httptoolkit/accounts": "^2.0.0",
"@httptoolkit/accounts": "^2.1.0",
"@httptoolkit/auth0-lock": "^11.26.3",
"@httptoolkit/httpsnippet": "^2.1.1",
"@open-rpc/meta-schema": "^1.14.2",
Expand Down
28 changes: 27 additions & 1 deletion src/model/account/account-store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash';
import { observable, action, flow, computed, when } from 'mobx';
import { observable, action, flow, computed, when, observe } from 'mobx';

import { logError, logErrorsAsUser } from '../../errors';
import { trackEvent } from '../../metrics';
Expand Down Expand Up @@ -76,6 +76,32 @@ export class AccountStore {
setInterval(this.updateUser, 1000 * 60 * 10);
loginEvents.on('logout', this.updateUser);

// Whenever account data updates, check if we're a non-user team admin, and notify (and
// logout) if so. This isn't a security measure (admin's dont get access anyway) it's just
// a UX question, as it can be confusing for admins otherwise when logging in doesn't work.
observe(this, 'accountDataLastUpdated', () => {
if (
!this.user.subscription &&
this.user.teamSubscription
) {
alert(
"You are the administrator of an HTTP Toolkit team, but you aren't listed " +
"as an active member, so you don't have access to HTTP Toolkit's " +
"paid features yourself." +
"\n\n" +
"To manage your team, please visit accounts.httptoolkit.tech."
);

window.open(
"https://accounts.httptoolkit.tech",
"_blank",
"noreferrer noopener"
);

this.logOut();
}
});

console.log('Account store initialized');
});

Expand Down

0 comments on commit 02c8d47

Please sign in to comment.