mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-04 01:18:20 +02:00
fix(signout): make signout works with proxy
This commit is contained in:
parent
4b64762671
commit
507f3c7ec1
@ -22,6 +22,7 @@ import AuthenticationContainer from './user/authentication-container';
|
|||||||
import ShowUserContainer from './user/show-user-container';
|
import ShowUserContainer from './user/show-user-container';
|
||||||
import ShowApiDetailsContainer from './api/show-api-details-container';
|
import ShowApiDetailsContainer from './api/show-api-details-container';
|
||||||
import { ScrollContainer } from 'react-router-scroll';
|
import { ScrollContainer } from 'react-router-scroll';
|
||||||
|
import { logoutUser } from '../store/user/actions';
|
||||||
|
|
||||||
function replace(input, params) {
|
function replace(input, params) {
|
||||||
if (!params) {
|
if (!params) {
|
||||||
@ -112,7 +113,7 @@ export default class App extends Component {
|
|||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const createListItem = (path, caption, icon, isDrawerNavigation = false, isAnchor = false) => {
|
const createListItem = (path, caption, icon, isDrawerNavigation = false) => {
|
||||||
const linkColor =
|
const linkColor =
|
||||||
isDrawerNavigation && this.context.router.isActive(path)
|
isDrawerNavigation && this.context.router.isActive(path)
|
||||||
? 'mdl-color-text--black'
|
? 'mdl-color-text--black'
|
||||||
@ -127,15 +128,7 @@ export default class App extends Component {
|
|||||||
className={isDrawerNavigation ? [styles.navigationIcon, iconColor].join(' ') : undefined}
|
className={isDrawerNavigation ? [styles.navigationIcon, iconColor].join(' ') : undefined}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return isAnchor ? (
|
return (
|
||||||
<a
|
|
||||||
href={path}
|
|
||||||
className={isDrawerNavigation ? [styles.navigationLink, linkColor].join(' ') : undefined}
|
|
||||||
>
|
|
||||||
{icon && renderIcon}
|
|
||||||
{caption}
|
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
<Link
|
<Link
|
||||||
to={path}
|
to={path}
|
||||||
className={isDrawerNavigation ? [styles.navigationLink, linkColor].join(' ') : undefined}
|
className={isDrawerNavigation ? [styles.navigationLink, linkColor].join(' ') : undefined}
|
||||||
@ -167,7 +160,7 @@ export default class App extends Component {
|
|||||||
{createListItem('/history', 'Event History', 'history', true)}
|
{createListItem('/history', 'Event History', 'history', true)}
|
||||||
{createListItem('/archive', 'Archived Toggles', 'archive', true)}
|
{createListItem('/archive', 'Archived Toggles', 'archive', true)}
|
||||||
{createListItem('/applications', 'Applications', 'apps', true)}
|
{createListItem('/applications', 'Applications', 'apps', true)}
|
||||||
{createListItem('/api/admin/user/logout', 'Sign out', 'exit_to_app', true, true)}
|
{createListItem('logout', 'Sign out', 'exit_to_app', true)}
|
||||||
</Navigation>
|
</Navigation>
|
||||||
<hr />
|
<hr />
|
||||||
<Navigation className={styles.navigation}>
|
<Navigation className={styles.navigation}>
|
||||||
@ -197,7 +190,7 @@ export default class App extends Component {
|
|||||||
{createListItem('/history', 'Event History', '')}
|
{createListItem('/history', 'Event History', '')}
|
||||||
{createListItem('/archive', 'Archived Toggles', '')}
|
{createListItem('/archive', 'Archived Toggles', '')}
|
||||||
{createListItem('/applications', 'Applications', '')}
|
{createListItem('/applications', 'Applications', '')}
|
||||||
<a href="/api/admin/user/logout">Sign out</a>
|
{createListItem('/logout', 'Sign out', '')}
|
||||||
</FooterLinkList>
|
</FooterLinkList>
|
||||||
</FooterDropDownSection>
|
</FooterDropDownSection>
|
||||||
<FooterDropDownSection title="Clients">
|
<FooterDropDownSection title="Clients">
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Feature from './feature-list-item-component';
|
import Feature from './feature-list-item-component';
|
||||||
import { Link } from 'react-router';
|
import { hashHistory, Link } from 'react-router';
|
||||||
import { Icon, FABButton, Textfield, Menu, MenuItem, Card, CardActions, List } from 'react-mdl';
|
import { Icon, FABButton, Textfield, Menu, MenuItem, Card, CardActions, List } from 'react-mdl';
|
||||||
|
|
||||||
import { MenuItemWithIcon, DropdownButton, styles as commonStyles } from '../common';
|
import { MenuItemWithIcon, DropdownButton, styles as commonStyles } from '../common';
|
||||||
import styles from './feature.scss';
|
import styles from './feature.scss';
|
||||||
|
|
||||||
@ -13,6 +12,7 @@ export default class FeatureListComponent extends React.Component {
|
|||||||
featureMetrics: PropTypes.object.isRequired,
|
featureMetrics: PropTypes.object.isRequired,
|
||||||
fetchFeatureToggles: PropTypes.func,
|
fetchFeatureToggles: PropTypes.func,
|
||||||
fetchArchive: PropTypes.func,
|
fetchArchive: PropTypes.func,
|
||||||
|
logoutUser: PropTypes.func,
|
||||||
revive: PropTypes.func,
|
revive: PropTypes.func,
|
||||||
updateSetting: PropTypes.func.isRequired,
|
updateSetting: PropTypes.func.isRequired,
|
||||||
toggleFeature: PropTypes.func,
|
toggleFeature: PropTypes.func,
|
||||||
@ -24,6 +24,10 @@ export default class FeatureListComponent extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
if (this.props.logout) {
|
||||||
|
this.props.logoutUser();
|
||||||
|
hashHistory.push(`/`);
|
||||||
|
}
|
||||||
if (this.props.fetchFeatureToggles) {
|
if (this.props.fetchFeatureToggles) {
|
||||||
this.props.fetchFeatureToggles();
|
this.props.fetchFeatureToggles();
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,7 @@ import { toggleFeature, fetchFeatureToggles } from '../../store/feature-actions'
|
|||||||
import { updateSettingForGroup } from '../../store/settings/actions';
|
import { updateSettingForGroup } from '../../store/settings/actions';
|
||||||
|
|
||||||
import FeatureListComponent from './list-component';
|
import FeatureListComponent from './list-component';
|
||||||
|
import { logoutUser } from '../../store/user/actions';
|
||||||
|
|
||||||
export const mapStateToPropsConfigurable = isFeature => state => {
|
export const mapStateToPropsConfigurable = isFeature => state => {
|
||||||
const featureMetrics = state.featureMetrics.toJS();
|
const featureMetrics = state.featureMetrics.toJS();
|
||||||
@ -71,6 +72,7 @@ export const mapStateToPropsConfigurable = isFeature => state => {
|
|||||||
};
|
};
|
||||||
const mapStateToProps = mapStateToPropsConfigurable(true);
|
const mapStateToProps = mapStateToPropsConfigurable(true);
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
|
logoutUser,
|
||||||
toggleFeature,
|
toggleFeature,
|
||||||
fetchFeatureToggles,
|
fetchFeatureToggles,
|
||||||
updateSetting: updateSettingForGroup('feature'),
|
updateSetting: updateSettingForGroup('feature'),
|
||||||
|
@ -2,6 +2,12 @@ import { throwIfNotSuccess, headers } from './helper';
|
|||||||
|
|
||||||
const URI = 'api/admin/user';
|
const URI = 'api/admin/user';
|
||||||
|
|
||||||
|
function logoutUser() {
|
||||||
|
return fetch(`${URI}/logout`, { method: 'GET', credentials: 'include' })
|
||||||
|
.then(throwIfNotSuccess)
|
||||||
|
.then(response => response.json());
|
||||||
|
}
|
||||||
|
|
||||||
function fetchUser() {
|
function fetchUser() {
|
||||||
return fetch(URI, { credentials: 'include' })
|
return fetch(URI, { credentials: 'include' })
|
||||||
.then(throwIfNotSuccess)
|
.then(throwIfNotSuccess)
|
||||||
@ -17,4 +23,5 @@ function unsecureLogin(path, user) {
|
|||||||
export default {
|
export default {
|
||||||
fetchUser,
|
fetchUser,
|
||||||
unsecureLogin,
|
unsecureLogin,
|
||||||
|
logoutUser,
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,7 @@ import Archive from './page/archive';
|
|||||||
import ShowArchive from './page/archive/show';
|
import ShowArchive from './page/archive/show';
|
||||||
import Applications from './page/applications';
|
import Applications from './page/applications';
|
||||||
import ApplicationView from './page/applications/view';
|
import ApplicationView from './page/applications/view';
|
||||||
|
import LogoutFeatures from './page/user/logout';
|
||||||
|
|
||||||
let composeEnhancers;
|
let composeEnhancers;
|
||||||
|
|
||||||
@ -76,6 +77,9 @@ ReactDOM.render(
|
|||||||
<Route pageTitle="Applications" path="/applications" component={Applications} />
|
<Route pageTitle="Applications" path="/applications" component={Applications} />
|
||||||
<Route pageTitle=":name" path="/applications/:name" component={ApplicationView} />
|
<Route pageTitle=":name" path="/applications/:name" component={ApplicationView} />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route pageTitle="Logout" link="/logout">
|
||||||
|
<Route pageTitle="Logout" path="/logout" component={LogoutFeatures} />
|
||||||
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
|
6
frontend/src/page/user/logout.js
Normal file
6
frontend/src/page/user/logout.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import FeatureListContainer from './../../component/feature/list-container';
|
||||||
|
|
||||||
|
const render = () => <FeatureListContainer logout />;
|
||||||
|
|
||||||
|
export default render;
|
@ -36,3 +36,7 @@ export function unsecureLogin(path, user) {
|
|||||||
.catch(handleError);
|
.catch(handleError);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logoutUser() {
|
||||||
|
return () => api.logoutUser().catch(handleError);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user