diff --git a/CHANGELOG.md b/CHANGELOG.md index fbfb1374496d82abc638d51f550e7bd25de7bf1b..205b7657999240ce77640b5921567a1bba34e00b 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 54519190334ff29afad1ce259a8c8c0f53f737ff..866cc47fad00159f57823e87e89125a9102a229f 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 71d8290ae1247449d3dd511b3648d9fecab080d5..b4e9637f56dc498e95e4fde35a9d98da79e9e949 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 7e361bdf71e167a048664b9ebd24ad36609a0794..a7c5079ef331302f35ab0165c54bed089439040c 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 cadb05426c71d71a226d73067f666a190ead0a6a..6d896c0d1d1c40131f551a1b3f26aa2b1b72d78a 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 eac8449b03074b54f2ae40f2e196f73da8aecd61..54af7c756bb5a8ae430d364043b6abdf07236f96 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 aa48a82f4d5bc8ac549b00ac69c5c412c91c17b7..b3d06fc8a8595b46f782591aeba75f1cfb642e50 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) => {