Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(auth): add back to login CTA on reset password token error screen (#11634)

SagarRajput-7f4e1465c1386
diff --git a/frontend/src/container/ResetPassword/ResetPassword.styles.scss b/frontend/src/container/ResetPassword/ResetPassword.styles.scss
index 92d660b0f5..22fc089d28 100644
--- a/frontend/src/container/ResetPassword/ResetPassword.styles.scss
+++ b/frontend/src/container/ResetPassword/ResetPassword.styles.scss
@@ -142,6 +142,15 @@
}
}
+ .reset-password-back-action {
+ margin-top: var(--spacing-12);
+ width: 100%;
+
+ button {
+ width: 100%;
+ }
+ }
+
@media (max-width: 768px) {
width: 100%;
padding: 0 16px;
diff --git a/frontend/src/container/ResetPassword/TokenError.tsx b/frontend/src/container/ResetPassword/TokenError.tsx
index fc9fe5862c..62673b4cce 100644
--- a/frontend/src/container/ResetPassword/TokenError.tsx
+++ b/frontend/src/container/ResetPassword/TokenError.tsx
@@ -1,7 +1,10 @@
-import { CircleAlert } from '@signozhq/icons';
+import { ArrowLeft, CircleAlert } from '@signozhq/icons';
+import { Button } from '@signozhq/ui/button';
import { Typography } from '@signozhq/ui/typography';
import AuthError from 'components/AuthError/AuthError';
import AuthPageContainer from 'components/AuthPageContainer';
+import ROUTES from 'constants/routes';
+import history from 'lib/history';
import APIError from 'types/api/error';
import './ResetPassword.styles.scss';
@@ -59,6 +62,16 @@ function TokenError({ error }: TokenErrorProps): JSX.Element {
</Typography.Text>
</div>
{error && <AuthError error={error} />}
+ <div className="reset-password-back-action">
+ <Button
+ variant="solid"
+ data-testid="back-to-login"
+ prefix={<ArrowLeft size={12} />}
+ onClick={(): void => history.push(ROUTES.LOGIN)}
+ >
+ Back to login
+ </Button>
+ </div>
</div>
</AuthPageContainer>
);
diff --git a/frontend/src/pages/ResetPassword/__tests__/ResetPasswordPage.test.tsx b/frontend/src/pages/ResetPassword/__tests__/ResetPasswordPage.test.tsx
index b55b06a173..a471d9f7db 100644
--- a/frontend/src/pages/ResetPassword/__tests__/ResetPasswordPage.test.tsx
+++ b/frontend/src/pages/ResetPassword/__tests__/ResetPasswordPage.test.tsx
@@ -2,7 +2,7 @@ import { Logout } from 'api/utils';
import ROUTES from 'constants/routes';
import history from 'lib/history';
import { createErrorResponse, rest, server } from 'mocks-server/server';
-import { render, screen, waitFor } from 'tests/test-utils';
+import { render, screen, waitFor, fireEvent } from 'tests/test-utils';
import ResetPassword from '../index';
@@ -103,6 +103,7 @@ describe('ResetPassword Page', () => {
expect(
screen.getByText(/reset password token does not exist/i),
).toBeInTheDocument();
+ expect(screen.getByTestId('back-to-login')).toBeInTheDocument();
});
it('shows "token is expired" when token is expired (401) without redirecting to login', async () => {
@@ -137,6 +138,32 @@ describe('ResetPassword Page', () => {
// 401 from this endpoint must NOT trigger logout/redirect
expect(mockHistoryPush).not.toHaveBeenCalledWith(ROUTES.LOGIN);
expect(Logout).not.toHaveBeenCalled();
+ expect(screen.getByTestId('back-to-login')).toBeInTheDocument();
+ });
+
+ it('navigates to login when "Back to login" is clicked on error screen', async () => {
+ server.use(
+ rest.post(
+ VERIFY_TOKEN_ENDPOINT,
+ createErrorResponse(
+ 404,
+ 'reset_password_token_not_found',
+ 'reset password token does not exist',
+ ),
+ ),
+ );
+
+ window.history.pushState({}, '', '/password-reset?token=invalid-token');
+ render(<ResetPassword />, undefined, {
+ initialRoute: '/password-reset?token=invalid-token',
+ });
+
+ await waitFor(() => {
+ expect(screen.getByTestId('back-to-login')).toBeInTheDocument();
+ });
+
+ fireEvent.click(screen.getByTestId('back-to-login'));
+ expect(mockHistoryPush).toHaveBeenCalledWith(ROUTES.LOGIN);
});
it('redirects to login when no token is in the URL', async () => {