Skip to content

Commit

Permalink
Always reauthenticate when token is unset (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
sslotsky authored Nov 4, 2019
1 parent ec3841d commit f392cb6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/manifold-auth-token/manifold-auth-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class ManifoldAuthToken {
componentWillLoad() {
this.setExternalToken(this.token);
if (this.subscribe) {
this.unsubscribe = this.subscribe((oldToken?: string, newToken?: string) => {
this.unsubscribe = this.subscribe((newToken?: string) => {
this.internalToken = newToken;
if (oldToken && !newToken) {
if (!newToken) {
// changing this to any new string will cause a token refresh. getTime() does that wonderfully.
this.tick = new Date().getTime().toString();
this.clear.emit();
Expand Down
2 changes: 1 addition & 1 deletion src/state/connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('connection state', () => {
const subscriber = jest.fn();
state.subscribe(subscriber);
state.setAuthToken('new-token');
expect(subscriber).toHaveBeenCalledWith('old-token', 'new-token');
expect(subscriber).toHaveBeenCalledWith('new-token');
});

it('will not notify after unsubscribing', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/state/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createRestFetch } from '../utils/restFetch';

const baseWait = 15000;

export type Subscriber = (oldToken?: string, newToken?: string) => void;
export type Subscriber = (newToken?: string) => void;

const INITIALIZED = 'manifold-connection-initialize';

Expand Down Expand Up @@ -56,7 +56,7 @@ export class ConnectionState {
};

setAuthToken = (token: string) => {
this.subscribers.forEach(s => s(this.authToken, token));
this.subscribers.forEach(s => s(token));
this.authToken = token;
};

Expand Down

1 comment on commit f392cb6

@vercel
Copy link

@vercel vercel bot commented on f392cb6 Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.