diff --git a/CHANGELOG.md b/CHANGELOG.md index fbfb1374496d..205b76579992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added documentation on how to mount cloud starage(AWS S3 bucket, Azure container, Google Drive) as FUSE () - Added ability to work with share files without copying inside () - Tooltips in label selectors () +- Page redirect after login using `next` query parameter () ### Changed diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 54519190334f..866cc47fad00 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.11.6", + "version": "1.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 71d8290ae124..b4e9637f56dc 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.11.6", + "version": "1.12.0", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 7e361bdf71e1..a7c5079ef331 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -233,16 +233,22 @@ class CVATApplication extends React.PureComponent )} - + {/* eslint-disable-next-line */} @@ -339,7 +348,9 @@ class CVATApplication extends React.PureComponent - + 1 ? `/auth/login/?next=${location.pathname}` : '/auth/login'} + /> ); diff --git a/cvat-ui/src/components/login-with-token/login-with-token.tsx b/cvat-ui/src/components/login-with-token/login-with-token.tsx index cadb05426c71..6d896c0d1d1c 100644 --- a/cvat-ui/src/components/login-with-token/login-with-token.tsx +++ b/cvat-ui/src/components/login-with-token/login-with-token.tsx @@ -3,15 +3,17 @@ // SPDX-License-Identifier: MIT import React, { useEffect } from 'react'; -import { Redirect, useParams } from 'react-router'; +import { Redirect, useParams, useLocation } from 'react-router'; import { useCookies } from 'react-cookie'; export default function LoginWithTokenComponent(): JSX.Element { - const { sessionId, token } = useParams(); + const location = useLocation(); + const { sessionId, token } = useParams<{ sessionId: string; token: string }>(); const [cookies, setCookie] = useCookies(['sessionid', 'csrftoken']); const expires1y = new Date(new Date().setFullYear(new Date().getFullYear() + 1)); const expires2w = new Date(new Date().setDate(new Date().getDate() + 13)); + const search = new URLSearchParams(location.search); setCookie('sessionid', sessionId, { path: '/', expires: expires2w }); setCookie('csrftoken', token, { path: '/', expires: expires1y }); @@ -24,7 +26,7 @@ export default function LoginWithTokenComponent(): JSX.Element { ); if (cookies.sessionid && cookies.csrftoken) { - return ; + return ; } return <>; } diff --git a/cvat-ui/src/reducers/auth-reducer.ts b/cvat-ui/src/reducers/auth-reducer.ts index eac8449b0307..54af7c756bb5 100644 --- a/cvat-ui/src/reducers/auth-reducer.ts +++ b/cvat-ui/src/reducers/auth-reducer.ts @@ -94,9 +94,9 @@ export default function (state = defaultState, action: AuthActions | BoundariesA return { ...state, showChangePasswordDialog: - typeof action.payload.showChangePasswordDialog === 'undefined' - ? !state.showChangePasswordDialog - : action.payload.showChangePasswordDialog, + typeof action.payload.showChangePasswordDialog === 'undefined' ? + !state.showChangePasswordDialog : + action.payload.showChangePasswordDialog, }; case AuthActionTypes.REQUEST_PASSWORD_RESET: return { diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index aa48a82f4d5b..b3d06fc8a859 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -23,6 +23,7 @@ Cypress.Commands.add('logout', (username = Cypress.env('user')) => { }); cy.get('.anticon-logout').click(); cy.url().should('include', '/auth/login'); + cy.visit('/auth/login'); // clear query parameter "next" }); Cypress.Commands.add('userRegistration', (firstName, lastName, userName, emailAddr, password) => {