Adapt to master changes

This commit is contained in:
Chi Vinh Le
2018-02-07 19:04:35 +01:00
parent 61bc372640
commit ffbcd93c3f
3 changed files with 25 additions and 22 deletions
@@ -23,7 +23,8 @@ class ForgotPassword extends React.Component {
renderSuccess() {
return (
<div className={styles.success} onClick={this.handleSignInLink}>
{this.props.success}{' '}
If you have a registered account, a password reset link was sent to that
email.{' '}
<a
className={styles.signInLink}
href="#"
+8 -6
View File
@@ -97,12 +97,14 @@ const CoralHeader = ({
Report a bug or give feedback
</a>
</MenuItem>
<MenuItem
onClick={handleLogout}
className="talk-admin-header-sign-out"
>
{t('configure.sign_out')}
</MenuItem>
{currentUser && (
<MenuItem
onClick={handleLogout}
className="talk-admin-header-sign-out"
>
{t('configure.sign_out')}
</MenuItem>
)}
</Menu>
</div>
</li>
+15 -15
View File
@@ -1,9 +1,9 @@
import * as actions from '../constants/auth';
import jwtDecode from 'jwt-decode';
function cleanAuthData(storage) {
storage.removeItem('token');
storage.removeItem('exp');
function cleanAuthData(localStorage) {
localStorage.removeItem('token');
localStorage.removeItem('exp');
}
/**
@@ -12,14 +12,14 @@ function cleanAuthData(storage) {
export const checkLogin = () => (
dispatch,
_,
{ rest, client, pym, storage }
{ rest, client, pym, localStorage }
) => {
dispatch(checkLoginRequest());
rest('/auth')
.then(result => {
if (!result.user) {
if (storage) {
cleanAuthData(storage);
if (localStorage) {
cleanAuthData(localStorage);
}
dispatch(checkLoginSuccess(null));
return;
@@ -32,9 +32,9 @@ export const checkLogin = () => (
pym.sendMessage('coral-auth-changed', JSON.stringify(result.user));
})
.catch(error => {
if (error.status && error.status === 401 && storage) {
if (error.status && error.status === 401 && localStorage) {
// Unauthorized.
cleanAuthData(storage);
cleanAuthData(localStorage);
} else {
console.error(error);
}
@@ -60,11 +60,11 @@ const checkLoginSuccess = user => ({
export const handleSuccessfulLogin = (user, token) => (
dispatch,
_,
{ client, storage }
{ client, localStorage }
) => {
if (storage) {
storage.setItem('exp', jwtDecode(token).exp);
storage.setItem('token', token);
if (localStorage) {
localStorage.setItem('exp', jwtDecode(token).exp);
localStorage.setItem('token', token);
}
client.resetWebsocket();
@@ -81,12 +81,12 @@ export const handleSuccessfulLogin = (user, token) => (
export const logout = () => async (
dispatch,
_,
{ rest, client, pym, storage }
{ rest, client, pym, localStorage }
) => {
await rest('/auth', { method: 'DELETE' });
if (storage) {
cleanAuthData(storage);
if (localStorage) {
cleanAuthData(localStorage);
}
// Reset the websocket.