Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay redirect for logged in users #87704

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/login/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ export async function login( context, next ) {
}

export function magicLogin( context, next ) {
const { path } = context;

if ( isUserLoggedIn( context.store.getState() ) ) {
return login( context, next );
}

const { path } = context;
context.primary = <MagicLogin path={ path } />;

next();
Expand All @@ -148,6 +147,10 @@ function getHandleEmailedLinkFormComponent( flow ) {
}

export function magicLoginUse( context, next ) {
if ( isUserLoggedIn( context.store.getState() ) ) {
return login( context, next );
}

/**
* Pull the query arguments out of the URL & into the state.
* It unclutters the address bar & will keep tokens out of tracking pixels.
Expand Down
2 changes: 0 additions & 2 deletions client/login/index.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import config from '@automattic/calypso-config';
import { getLanguageRouteParam } from '@automattic/i18n-utils';
import { makeLayout, setLocaleMiddleware } from 'calypso/controller';
import webRouter from './index.web';
import redirectLoggedIn from './redirect-logged-in';

/**
* Re-exports
Expand All @@ -17,7 +16,6 @@ export default ( router ) => {
router(
[ `/log-in/link/use/${ lang }`, `/log-in/link/jetpack/use/${ lang }` ],
setLocaleMiddleware(),
redirectLoggedIn,
makeLayout
);
}
Expand Down
1 change: 0 additions & 1 deletion client/login/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default ( router ) => {
if ( config.isEnabled( 'login/magic-login' ) ) {
router(
[ `/log-in/link/use/${ lang }`, `/log-in/jetpack/link/use/${ lang }` ],
redirectLoggedIn,
setLocaleMiddleware(),
setSectionMiddleware( LOGIN_SECTION_DEFINITION ),
magicLoginUse,
Expand Down
Loading