diff --git a/ui/src/Logout.tsx b/ui/src/Logout.tsx index c2d89729e2..c53d38d966 100644 --- a/ui/src/Logout.tsx +++ b/ui/src/Logout.tsx @@ -22,7 +22,14 @@ export class Logout extends PureComponent { private handleSignOut = async () => { await logout() - this.props.router.push('/') + const {query} = this.props.location + let returnTo = '' + + if (query && query.returnTo) { + returnTo = `?returnTo=${query.returnTo}` + } + + this.props.router.push(`/signin${returnTo}`) } } diff --git a/ui/src/Signin.tsx b/ui/src/Signin.tsx index 4614039ac9..d4345797ee 100644 --- a/ui/src/Signin.tsx +++ b/ui/src/Signin.tsx @@ -62,8 +62,22 @@ export class Signin extends PureComponent { try { await getMe() } catch (error) { + const { + location: {pathname}, + } = this.props clearInterval(this.intervalID) - this.props.router.push('/signin') + + if (pathname.startsWith('/signin')) { + return + } + + let returnTo = '' + + if (pathname !== '/') { + returnTo = `?returnTo=${pathname}` + } + + this.props.router.push(`/signin${returnTo}`) } } } diff --git a/ui/src/me/components/LogoutButton.tsx b/ui/src/me/components/LogoutButton.tsx index 7d9cbddff8..14ed239245 100644 --- a/ui/src/me/components/LogoutButton.tsx +++ b/ui/src/me/components/LogoutButton.tsx @@ -1,14 +1,15 @@ // Libraries import React, {SFC} from 'react' import {Link} from 'react-router' +import {withRouter, WithRouterProps} from 'react-router' // Components import {Button, ComponentSize} from 'src/clockface' -const LogoutButton: SFC = () => ( - +const LogoutButton: SFC = props => ( +