mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 23:26:48 +08:00
9566f83eac
Some of them were only related to the embed stream. Auth code is too convoluted with the embed stream and can't be reused atm.
33 lines
1021 B
JavaScript
33 lines
1021 B
JavaScript
import React from 'react';
|
|
import styles from './styles.css';
|
|
import {connect} from 'react-redux';
|
|
import {bindActionCreators} from 'redux';
|
|
import t from 'coral-framework/services/i18n';
|
|
import {logout} from 'coral-embed-stream/src/actions/auth';
|
|
|
|
const UserBox = ({loggedIn, user, logout, onShowProfile}) => (
|
|
<div>
|
|
{
|
|
loggedIn ? (
|
|
<div className={`${styles.userBox} talk-stream-auth-userbox`}>
|
|
<span className={styles.userBoxLoggedIn}>{t('sign_in.logged_in_as')}</span>
|
|
<a onClick={onShowProfile}>{user.username}</a>. {t('sign_in.not_you')}
|
|
<a className={`${styles.logout} talk-stream-userbox-logout`} onClick={() => logout()}>
|
|
{t('sign_in.logout')}
|
|
</a>
|
|
</div>
|
|
) : null
|
|
}
|
|
</div>
|
|
);
|
|
|
|
const mapStateToProps = ({auth}) => ({
|
|
loggedIn: auth.loggedIn,
|
|
user: auth.user
|
|
});
|
|
|
|
const mapDispatchToProps = (dispatch) =>
|
|
bindActionCreators({logout}, dispatch);
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(UserBox);
|