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

Redirect query param
main
Boris Sekachev 5 years ago committed by GitHub
commit 76ff7eff03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 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>) - 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>) - 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 ### Changed

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.11.6", "version": "1.12.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.11.6", "version": "1.12.0",
"description": "CVAT single-page application", "description": "CVAT single-page application",
"main": "src/index.tsx", "main": "src/index.tsx",
"scripts": { "scripts": {

@ -233,16 +233,22 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
aboutInitialized, aboutInitialized,
pluginsInitialized, pluginsInitialized,
formatsInitialized, formatsInitialized,
modelsInitialized,
switchShortcutsDialog, switchShortcutsDialog,
switchSettingsDialog, switchSettingsDialog,
user, user,
keyMap, keyMap,
location,
isModelPluginActive, isModelPluginActive,
} = this.props; } = this.props;
const readyForRender = const readyForRender =
(userInitialized && (user == null || !user.isVerified)) || (userInitialized && (user == null || !user.isVerified)) ||
(userInitialized && formatsInitialized && pluginsInitialized && aboutInitialized); (userInitialized &&
formatsInitialized &&
pluginsInitialized &&
aboutInitialized &&
(!isModelPluginActive || modelsInitialized));
const subKeyMap = { const subKeyMap = {
SWITCH_SHORTCUTS: keyMap.SWITCH_SHORTCUTS, SWITCH_SHORTCUTS: keyMap.SWITCH_SHORTCUTS,
@ -312,7 +318,10 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
{isModelPluginActive && ( {isModelPluginActive && (
<Route exact path='/models' component={ModelsPageContainer} /> <Route exact path='/models' component={ModelsPageContainer} />
)} )}
<Redirect push to='/tasks' /> <Redirect
push
to={new URLSearchParams(location.search).get('next') || '/tasks'}
/>
</Switch> </Switch>
</GlobalHotKeys> </GlobalHotKeys>
{/* eslint-disable-next-line */} {/* eslint-disable-next-line */}
@ -339,7 +348,9 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
path='/auth/password/reset/confirm' path='/auth/password/reset/confirm'
component={ResetPasswordPageConfirmComponent} component={ResetPasswordPageConfirmComponent}
/> />
<Redirect to='/auth/login' /> <Redirect
to={location.pathname.length > 1 ? `/auth/login/?next=${location.pathname}` : '/auth/login'}
/>
</Switch> </Switch>
</GlobalErrorBoundary> </GlobalErrorBoundary>
); );

@ -3,15 +3,17 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { Redirect, useParams } from 'react-router'; import { Redirect, useParams, useLocation } from 'react-router';
import { useCookies } from 'react-cookie'; import { useCookies } from 'react-cookie';
export default function LoginWithTokenComponent(): JSX.Element { 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 [cookies, setCookie] = useCookies(['sessionid', 'csrftoken']);
const expires1y = new Date(new Date().setFullYear(new Date().getFullYear() + 1)); const expires1y = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
const expires2w = new Date(new Date().setDate(new Date().getDate() + 13)); const expires2w = new Date(new Date().setDate(new Date().getDate() + 13));
const search = new URLSearchParams(location.search);
setCookie('sessionid', sessionId, { path: '/', expires: expires2w }); setCookie('sessionid', sessionId, { path: '/', expires: expires2w });
setCookie('csrftoken', token, { path: '/', expires: expires1y }); setCookie('csrftoken', token, { path: '/', expires: expires1y });
@ -24,7 +26,7 @@ export default function LoginWithTokenComponent(): JSX.Element {
); );
if (cookies.sessionid && cookies.csrftoken) { if (cookies.sessionid && cookies.csrftoken) {
return <Redirect to='/tasks' />; return <Redirect to={search.get('next') || '/tasks'} />;
} }
return <></>; return <></>;
} }

@ -94,9 +94,9 @@ export default function (state = defaultState, action: AuthActions | BoundariesA
return { return {
...state, ...state,
showChangePasswordDialog: showChangePasswordDialog:
typeof action.payload.showChangePasswordDialog === 'undefined' typeof action.payload.showChangePasswordDialog === 'undefined' ?
? !state.showChangePasswordDialog !state.showChangePasswordDialog :
: action.payload.showChangePasswordDialog, action.payload.showChangePasswordDialog,
}; };
case AuthActionTypes.REQUEST_PASSWORD_RESET: case AuthActionTypes.REQUEST_PASSWORD_RESET:
return { return {

@ -23,6 +23,7 @@ Cypress.Commands.add('logout', (username = Cypress.env('user')) => {
}); });
cy.get('.anticon-logout').click(); cy.get('.anticon-logout').click();
cy.url().should('include', '/auth/login'); cy.url().should('include', '/auth/login');
cy.visit('/auth/login'); // clear query parameter "next"
}); });
Cypress.Commands.add('userRegistration', (firstName, lastName, userName, emailAddr, password) => { Cypress.Commands.add('userRegistration', (firstName, lastName, userName, emailAddr, password) => {

Loading…
Cancel
Save