Skip to content

Commit

Permalink
fix: login bug when both anonymous and auth is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Raul-Cristian Kele <[email protected]>
  • Loading branch information
raulkele committed Jun 16, 2023
1 parent 936590d commit a552487
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/components/Login/SignIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
import { host } from '../../host';
// utility
import { api, endpoints } from '../../api';
import { isEmpty } from 'lodash';
import { isEmpty, isNil } from 'lodash';

// components
import Button from '@mui/material/Button';
Expand Down Expand Up @@ -142,17 +142,18 @@ export default function SignIn({ isLoggedIn, setIsLoggedIn, wrapperSetLoading =
event.preventDefault();
setRequestProcessing(true);
let cfg = {};
const token = btoa(username + ':' + password);
cfg = {
headers: {
Authorization: `Basic ${token}`
}
};
let token = !isNil(username) && !isNil(password) ? btoa(username + ':' + password) : '-';
if (token !== '-') {
cfg = {
headers: {
Authorization: `Basic ${token}`
}
};
}
api
.get(`${host()}/v2/`, abortController.signal, cfg)
.then((response) => {
if (response.status === 200) {
const token = btoa(username + ':' + password);
localStorage.setItem('token', token);
setRequestProcessing(false);
setRequestError(false);
Expand Down
3 changes: 0 additions & 3 deletions tests/tag.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test, expect } from '@playwright/test';
import { getTagWithDependencies, getTagWithDependents, getTagWithVulnerabilities } from './utils/test-data-parser';
import { hosts, pageSizes } from './values/test-constants';
import { scroll } from './utils/scroll';

test.describe('Tag page test', () => {
test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -39,7 +38,5 @@ test.describe('Tag page test', () => {
await expect(page.getByTestId('vulnerability-container').locator('div').nth(1)).toBeVisible({ timeout: 100000 });
await expect(await page.getByText('CVE-').count()).toBeGreaterThan(1);
await expect(await page.getByText('CVE-').count()).toBeLessThanOrEqual(pageSizes.EXPLORE);
await page.evaluate(scroll, { direction: 'down', speed: 'fast' });
await expect(await page.getByText('CVE-').count()).toBeGreaterThanOrEqual(pageSizes.EXPLORE);
});
});

0 comments on commit a552487

Please sign in to comment.