mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Do not expose logout action to route
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
export class Logout extends Component {
|
||||
static displayName = 'Logout';
|
||||
|
||||
render() {
|
||||
return <span/>;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { routeActions } from 'react-router-redux';
|
||||
|
||||
import request from 'services/request';
|
||||
import accounts from 'services/api/accounts';
|
||||
|
||||
@@ -22,7 +24,10 @@ export function setUser(payload) {
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
return setUser({isGuest: true});
|
||||
return (dispatch) => {
|
||||
dispatch(setUser({isGuest: true}));
|
||||
dispatch(routeActions.push('/login'));
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchUserData() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { Link } from 'react-router';
|
||||
import { intlShape, FormattedMessage as Message } from 'react-intl';
|
||||
import { intlShape } from 'react-intl';
|
||||
|
||||
import buttons from 'components/ui/buttons.scss';
|
||||
import buttonGroups from 'components/ui/button-groups.scss';
|
||||
@@ -15,7 +15,8 @@ import { userShape } from 'components/user/User';
|
||||
export default class LoggedInPanel extends Component {
|
||||
static displayName = 'LoggedInPanel';
|
||||
static propTypes = {
|
||||
user: userShape
|
||||
user: userShape,
|
||||
onLogout: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
static contextTypes = {
|
||||
@@ -31,14 +32,20 @@ export default class LoggedInPanel extends Component {
|
||||
<span className={styles.userIcon} />
|
||||
<span className={styles.userName}>{user.username}</span>
|
||||
</Link>
|
||||
<Link
|
||||
to="/logout"
|
||||
<button
|
||||
onClick={this.onLogout}
|
||||
className={classNames(buttons.green, buttonGroups.item)}
|
||||
title={this.context.intl.formatMessage(messages.logout)}
|
||||
>
|
||||
<span className={styles.logoutIcon} />
|
||||
</Link>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onLogout = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
this.props.onLogout();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user