-
Notifications
You must be signed in to change notification settings - Fork 14
[OGUI-1752] TanStack auth setup #3183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
db29663
chore: add axios request interceptor
sKrzysieK 42e335a
chore: implement useAuth hook
sKrzysieK 89ba436
chore: modify user section
sKrzysieK 31ba374
chore: modify tests
sKrzysieK e450f68
chore: review mui fixes
sKrzysieK 995ae11
Merge branch 'dev' into feature/CNF/OGUI-1752/tanstack-auth
Deaponn b703258
Merge branch 'dev' into feature/CNF/OGUI-1752/tanstack-auth
sKrzysieK b90660d
chore: modify timeouts
sKrzysieK 1f24dcd
chore: add axiosInstance unit tests
sKrzysieK 50c99c3
chore: fix eslint
sKrzysieK a235043
fix: add user agent
sKrzysieK 275c03b
Merge branch 'dev' into feature/CNF/OGUI-1752/tanstack-auth
graduta 5944406
chore: refactor tests
sKrzysieK a4cf5e9
chore: fix possibly null header text
sKrzysieK 6a96e3b
Merge branch 'dev' into feature/CNF/OGUI-1752/tanstack-auth
sKrzysieK 39acdb7
fix: remove unused imports
sKrzysieK 356d9cf
feature: replace fontawesome icons with mui icons
Deaponn da3c32d
revert: commit 356d9cf
Deaponn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { useEffect, useState } from 'react'; | ||
| import { getSessionData } from '~/services/session'; | ||
|
|
||
| export interface Session { | ||
| personid: string; | ||
sKrzysieK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| username: string; | ||
| name: string; | ||
| access: string; | ||
| token: string; | ||
| } | ||
|
|
||
| export const useAuth = (): Session => { | ||
| const [session, setSession] = useState<Record<string, string>>({}); | ||
|
|
||
| useEffect(() => { | ||
| const fetchSession = async () => { | ||
| const session = await getSessionData(); | ||
| setSession(session); | ||
| }; | ||
| void fetchSession(); | ||
| }, []); | ||
|
|
||
| return session as unknown as Session; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import assert from 'assert'; | ||
|
|
||
| const BAD_REQUEST_ERROR_CODE = 'ERR_BAD_REQUEST'; | ||
|
|
||
| //test Configuration/webapp/app/api/axiosInstance.ts | ||
| import axiosInstance, { API_URL } from '../../app/api/axiosInstance'; | ||
|
|
||
| describe('axios instance', function () { | ||
| this.timeout(20000); | ||
|
|
||
| it('should make a GET request and receive a response', async function () { | ||
| const response = await axiosInstance.get(`${API_URL}/configurations`); | ||
| assert.strictEqual(response.status, 200); | ||
| }); | ||
|
|
||
| it('should handle error response correctly', async function () { | ||
| try { | ||
| await axiosInstance.get(`${API_URL}/not-existing`); | ||
| } catch (error: unknown) { | ||
| if (typeof error === 'object' && error !== null && 'code' in error) { | ||
| assert.strictEqual(error.code, BAD_REQUEST_ERROR_CODE); | ||
| } else { | ||
| assert.fail('Error object does not have code property'); | ||
| } | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.