Skip to content

Commit 4ffed05

Browse files
Release v1.138.1 - staging → master
Fixed Authentication redirect issue (#11925) Release v1.138.1 - staging → master
2 parents 68d1982 + bb7e7f8 commit 4ffed05

32 files changed

+886
-465
lines changed

packages/manager/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [2025-03-26] - v1.138.1
8+
9+
### Fixed:
10+
11+
- Authentication redirect issue ([#11925](https://github.com/linode/manager/pull/11925))
12+
713
## [2025-03-25] - v1.138.0
814

915

packages/manager/cypress/e2e/core/parentChild/token-expiration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ describe('Parent/Child token expiration', () => {
7878
.click();
7979
});
8080

81-
cy.url().should('endWith', '/login');
81+
cy.url().should('endWith', '/logout');
8282
});
8383
});

packages/manager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "linode-manager",
33
"author": "Linode",
44
"description": "The Linode Manager website",
5-
"version": "1.138.0",
5+
"version": "1.138.1",
66
"private": true,
77
"type": "module",
88
"bugs": {

packages/manager/src/components/AccessPanel/UserSSHKeyPanel.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('UserSSHKeyPanel', () => {
2222
return HttpResponse.json(makeResourcePage([]));
2323
}),
2424
http.get('*/account/users', () => {
25-
return HttpResponse.json(makeResourcePage([]));
25+
return HttpResponse.json(makeResourcePage([]), { status: 401 });
2626
})
2727
);
2828
const { queryByTestId } = renderWithTheme(
@@ -46,7 +46,7 @@ describe('UserSSHKeyPanel', () => {
4646
return HttpResponse.json(makeResourcePage(sshKeys));
4747
}),
4848
http.get('*/account/users', () => {
49-
return HttpResponse.json(makeResourcePage([]));
49+
return HttpResponse.json(makeResourcePage([]), { status: 401 });
5050
})
5151
);
5252
const { getByText } = renderWithTheme(

packages/manager/src/features/Account/SwitchAccountDrawer.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { NotFound } from 'src/components/NotFound';
66
import { PARENT_USER_SESSION_EXPIRED } from 'src/features/Account/constants';
77
import { useParentChildAuthentication } from 'src/features/Account/SwitchAccounts/useParentChildAuthentication';
88
import { setTokenInLocalStorage } from 'src/features/Account/SwitchAccounts/utils';
9+
import { useCurrentToken } from 'src/hooks/useAuthentication';
910
import { sendSwitchToParentAccountEvent } from 'src/utilities/analytics/customEventAnalytics';
10-
import { getAuthToken } from 'src/utilities/authentication';
1111
import { getStorage, setStorage } from 'src/utilities/storage';
1212

1313
import { ChildAccountList } from './SwitchAccounts/ChildAccountList';
1414
import { updateParentTokenInLocalStorage } from './SwitchAccounts/utils';
1515

1616
import type { APIError, UserType } from '@linode/api-v4';
17+
import type { State as AuthState } from 'src/store/authentication';
1718

1819
interface Props {
1920
onClose: () => void;
@@ -22,7 +23,7 @@ interface Props {
2223
}
2324

2425
interface HandleSwitchToChildAccountProps {
25-
currentTokenWithBearer?: string;
26+
currentTokenWithBearer?: AuthState['token'];
2627
euuid: string;
2728
event: React.MouseEvent<HTMLElement>;
2829
onClose: (e: React.SyntheticEvent<HTMLElement>) => void;
@@ -38,9 +39,9 @@ export const SwitchAccountDrawer = (props: Props) => {
3839
const [query, setQuery] = React.useState<string>('');
3940

4041
const isProxyUser = userType === 'proxy';
41-
const currentParentTokenWithBearer: string =
42+
const currentParentTokenWithBearer =
4243
getStorage('authentication/parent_token/token') ?? '';
43-
const currentTokenWithBearer = getAuthToken().token;
44+
const currentTokenWithBearer = useCurrentToken() ?? '';
4445

4546
const {
4647
createToken,

packages/manager/src/features/Account/SwitchAccounts/useParentChildAuthentication.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {
1010
isParentTokenValid,
1111
updateCurrentTokenBasedOnUserType,
1212
} from 'src/features/Account/SwitchAccounts/utils';
13-
import { getAuthToken } from 'src/utilities/authentication';
13+
import { useCurrentToken } from 'src/hooks/useAuthentication';
1414
import { getStorage } from 'src/utilities/storage';
1515

1616
import type { Token, UserType } from '@linode/api-v4';
1717

1818
export const useParentChildAuthentication = () => {
19-
const currentTokenWithBearer = getAuthToken().token;
19+
const currentTokenWithBearer = useCurrentToken() ?? '';
2020

2121
const {
2222
error: createTokenError,

packages/manager/src/features/Account/SwitchAccounts/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getStorage, setStorage } from 'src/utilities/storage';
22

33
import type { Token, UserType } from '@linode/api-v4';
4+
import type { State as AuthState } from 'src/store/authentication';
45

56
export interface ProxyTokenCreationParams {
67
/**
@@ -20,7 +21,7 @@ export interface ProxyTokenCreationParams {
2021
export const updateParentTokenInLocalStorage = ({
2122
currentTokenWithBearer,
2223
}: {
23-
currentTokenWithBearer?: string;
24+
currentTokenWithBearer?: AuthState['token'];
2425
}) => {
2526
const parentToken: Token = {
2627
created: getStorage('authentication/created'),

packages/manager/src/features/Profile/DisplaySettings/TimezoneForm.test.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as React from 'react';
33

44
import { profileFactory } from 'src/factories';
55
import { HttpResponse, http, server } from 'src/mocks/testServer';
6-
import { clearAuthToken, setAuthToken } from 'src/utilities/authentication';
76
import { renderWithTheme } from 'src/utilities/testHelpers';
87

98
import { TimezoneForm, getOptionLabel } from './TimezoneForm';
@@ -19,8 +18,6 @@ describe('Timezone change form', () => {
1918
);
2019
})
2120
);
22-
23-
clearAuthToken();
2421
});
2522

2623
it('should render input label', () => {
@@ -30,9 +27,9 @@ describe('Timezone change form', () => {
3027
});
3128

3229
it('should show a message if an admin is logged in as a customer', async () => {
33-
setAuthToken({ expiration: 'never', scopes: '*', token: 'admin 123' });
34-
35-
const { getByTestId } = renderWithTheme(<TimezoneForm />);
30+
const { getByTestId } = renderWithTheme(<TimezoneForm />, {
31+
customStore: { authentication: { loggedInAsCustomer: true } },
32+
});
3633

3734
expect(getByTestId('admin-notice')).toBeInTheDocument();
3835
});
@@ -44,9 +41,9 @@ describe('Timezone change form', () => {
4441
});
4542

4643
it("should include text with the user's current time zone in the admin warning", async () => {
47-
setAuthToken({ expiration: 'never', scopes: '*', token: 'admin 123' });
48-
49-
const { queryByTestId } = renderWithTheme(<TimezoneForm />);
44+
const { queryByTestId } = renderWithTheme(<TimezoneForm />, {
45+
customStore: { authentication: { loggedInAsCustomer: true } },
46+
});
5047

5148
await waitFor(() => {
5249
expect(queryByTestId('admin-notice')).toHaveTextContent(

packages/manager/src/features/Profile/DisplaySettings/TimezoneForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as React from 'react';
77
import { Controller, useForm } from 'react-hook-form';
88

99
import { timezones } from 'src/assets/timezones/timezones';
10-
import { isLoggedInAsCustomer } from 'src/utilities/authentication';
10+
import { useAuthentication } from 'src/hooks/useAuthentication';
1111

1212
import type { Profile } from '@linode/api-v4';
1313

@@ -40,6 +40,7 @@ const timezoneOptions = getTimezoneOptions();
4040
type Values = Pick<Profile, 'timezone'>;
4141

4242
export const TimezoneForm = () => {
43+
const { loggedInAsCustomer } = useAuthentication();
4344
const { enqueueSnackbar } = useSnackbar();
4445
const { data: profile } = useProfile();
4546
const { mutateAsync: updateProfile } = useMutateProfile();
@@ -67,7 +68,7 @@ export const TimezoneForm = () => {
6768

6869
return (
6970
<form onSubmit={handleSubmit(onSubmit)}>
70-
{isLoggedInAsCustomer() && (
71+
{loggedInAsCustomer && (
7172
<Notice dataTestId="admin-notice" variant="error">
7273
While you are logged in as a customer, all times, dates, and graphs
7374
will be displayed in the user&rsquo;s timezone ({profile?.timezone}).

packages/manager/src/features/TopMenu/TopMenu.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AppBar } from 'src/components/AppBar';
77
import { Link } from 'src/components/Link';
88
import { StyledAkamaiLogo } from 'src/components/PrimaryNav/PrimaryNav.styles';
99
import { Toolbar } from 'src/components/Toolbar';
10-
import { isLoggedInAsCustomer } from 'src/utilities/authentication';
10+
import { useAuthentication } from 'src/hooks/useAuthentication';
1111

1212
import { Community } from './Community';
1313
import { CreateMenu } from './CreateMenu/CreateMenu';
@@ -36,6 +36,8 @@ export interface TopMenuProps {
3636
export const TopMenu = React.memo((props: TopMenuProps) => {
3737
const { openSideMenu, username } = props;
3838

39+
const { loggedInAsCustomer } = useAuthentication();
40+
3941
const isNarrowViewport = useMediaQuery((theme: Theme) =>
4042
theme.breakpoints.down(960)
4143
);
@@ -45,7 +47,7 @@ export const TopMenu = React.memo((props: TopMenuProps) => {
4547

4648
return (
4749
<>
48-
{isLoggedInAsCustomer() && <InternalAdminBanner username={username} />}
50+
{loggedInAsCustomer && <InternalAdminBanner username={username} />}
4951
<AppBar data-qa-appbar>
5052
<Toolbar variant="dense">
5153
{isNarrowViewport && (

0 commit comments

Comments
 (0)