Restore login flow in ProfileContainer

This commit is contained in:
Chi Vinh Le
2017-04-21 00:52:45 +07:00
parent 6df2103da3
commit f0e584f0b3
2 changed files with 6 additions and 16 deletions
@@ -4,10 +4,10 @@ import translations from '../translations';
import I18n from 'coral-framework/modules/i18n/i18n';
const lang = new I18n(translations);
export default ({signIn}) => (
export default ({showSignInDialog}) => (
<div className={styles.message}>
<div>
<a onClick={signIn}>{lang.t('signIn')}</a> {lang.t('toAccess')}
<a onClick={showSignInDialog}>{lang.t('signIn')}</a> {lang.t('toAccess')}
</div>
<div>
{lang.t('fromSettingsPage')}
@@ -13,7 +13,7 @@ import IgnoredUsers from '../components/IgnoredUsers';
import {Spinner} from 'coral-ui';
import CommentHistory from 'coral-plugin-history/CommentHistory';
import {openSignInPopUp, checkLogin} from 'coral-framework/actions/auth';
import {showSignInDialog, checkLogin} from 'coral-framework/actions/auth';
import translations from '../translations';
const lang = new I18n(translations);
@@ -34,18 +34,8 @@ class ProfileContainer extends Component {
});
}
signIn = () => {
const {refetch} = this.props.data;
const {openSignInPopUp, checkLogin} = this.props;
openSignInPopUp(() => {
checkLogin();
refetch();
});
}
render() {
const {loggedIn, asset, data, myIgnoredUsersData, stopIgnoringUser} = this.props;
const {loggedIn, asset, data, showSignInDialog, myIgnoredUsersData, stopIgnoringUser} = this.props;
const {me} = this.props.data;
if (data.loading) {
@@ -53,7 +43,7 @@ class ProfileContainer extends Component {
}
if (!loggedIn || !me) {
return <NotLoggedIn signIn={this.signIn} />;
return <NotLoggedIn showSignInDialog={showSignInDialog} />;
}
const localProfile = this.props.user.profiles.find(p => p.provider === 'local');
@@ -106,7 +96,7 @@ const mapStateToProps = state => ({
});
const mapDispatchToProps = dispatch =>
bindActionCreators({openSignInPopUp, checkLogin}, dispatch);
bindActionCreators({showSignInDialog, checkLogin}, dispatch);
export default compose(
connect(mapStateToProps, mapDispatchToProps),