mirror of
https://github.com/wassname/talk.git
synced 2026-07-23 13:10:20 +08:00
Adapt to master changes
This commit is contained in:
@@ -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="#"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user