未验证 提交 76ff7eff 编写于 作者: B Boris Sekachev 提交者: GitHub

Merge pull request #2527 from openvinotoolkit/dk/login-redirect

Redirect query param
......@@ -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 (<https://github.com/openvinotoolkit/cvat/pull/2377>)
- Added ability to work with share files without copying inside (<https://github.com/openvinotoolkit/cvat/pull/2377>)
- Tooltips in label selectors (<https://github.com/openvinotoolkit/cvat/pull/2509>)
- Page redirect after login using `next` query parameter (<https://github.com/openvinotoolkit/cvat/pull/2527>)
### Changed
......
{
"name": "cvat-ui",
"version": "1.11.6",
"version": "1.12.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
{
"name": "cvat-ui",
"version": "1.11.6",
"version": "1.12.0",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
......
......@@ -233,16 +233,22 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
aboutInitialized,
pluginsInitialized,
formatsInitialized,
modelsInitialized,
switchShortcutsDialog,
switchSettingsDialog,
user,
keyMap,
location,
isModelPluginActive,
} = this.props;
const readyForRender =
(userInitialized && (user == null || !user.isVerified)) ||
(userInitialized && formatsInitialized && pluginsInitialized && aboutInitialized);
(userInitialized &&
formatsInitialized &&
pluginsInitialized &&
aboutInitialized &&
(!isModelPluginActive || modelsInitialized));
const subKeyMap = {
SWITCH_SHORTCUTS: keyMap.SWITCH_SHORTCUTS,
......@@ -312,7 +318,10 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
{isModelPluginActive && (
<Route exact path='/models' component={ModelsPageContainer} />
)}
<Redirect push to='/tasks' />
<Redirect
push
to={new URLSearchParams(location.search).get('next') || '/tasks'}
/>
</Switch>
</GlobalHotKeys>
{/* eslint-disable-next-line */}
......@@ -339,7 +348,9 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
path='/auth/password/reset/confirm'
component={ResetPasswordPageConfirmComponent}
/>
<Redirect to='/auth/login' />
<Redirect
to={location.pathname.length > 1 ? `/auth/login/?next=${location.pathname}` : '/auth/login'}
/>
</Switch>
</GlobalErrorBoundary>
);
......
......@@ -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 <Redirect to='/tasks' />;
return <Redirect to={search.get('next') || '/tasks'} />;
}
return <></>;
}
......@@ -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 {
......
......@@ -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) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册