Skip to content

Commit

Permalink
BED-4666: remove logout on 401 /features (#768)
Browse files Browse the repository at this point in the history
* fix: logout on 401 /features

* refactor: reject with error instead of early return

* refactor: replace bang operator
  • Loading branch information
benwaples authored Aug 2, 2024
1 parent d202784 commit b302b6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/ui/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { isLink, isNode } from 'src/ducks/graph/utils';
import { Glyph } from 'src/rendering/programs/node.glyphs';
import { store } from 'src/store';

const IGNORE_401_LOGOUT = ['/api/v2/login', '/api/v2/logout', '/api/v2/features']

export const getDatesInRange = (startDate: Date, endDate: Date) => {
const date = new Date(startDate.getTime());

Expand Down Expand Up @@ -74,12 +76,10 @@ export const initializeBHEClient = () => {

(error) => {
if (error?.response) {
if (
error?.response?.status === 401 &&
error?.response?.config.url !== '/api/v2/login' &&
error?.response?.config.url !== '/api/v2/logout'
) {
throttledLogout();
if (error?.response?.status === 401) {
if (IGNORE_401_LOGOUT.includes(error?.response?.config.url) === false) {
throttledLogout();
}
} else if (
error?.response?.status === 403 &&
!error?.response?.config.url.match('/api/v2/bloodhound-users/[a-z0-9-]+/secret')
Expand Down

0 comments on commit b302b6e

Please sign in to comment.