Skip to content

Commit

Permalink
chore(ui): perform token validity check (#2866)
Browse files Browse the repository at this point in the history
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
  • Loading branch information
Marvin9 authored Oct 29, 2024
1 parent d54c784 commit 5366f30
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/src/config/transport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConnectError, Interceptor } from '@connectrpc/connect';
import { Code, ConnectError, Interceptor } from '@connectrpc/connect';
import { createConnectTransport } from '@connectrpc/connect-web';
import { notification } from 'antd';

Expand Down Expand Up @@ -55,6 +55,12 @@ export const newErrorHandler = (handler: (err: ConnectError) => void): Intercept

handler(err);

// in rare cases, token is invalid but UI could not detect it beforehand
// CodeUnauthenticated <- to ease the global code search
if (err instanceof ConnectError && err?.code === Code.Unauthenticated) {
logout();
}

throw err;
});
};
Expand Down

0 comments on commit 5366f30

Please sign in to comment.