Browse Source

proper logout

all-modes
pbca26 8 years ago
parent
commit
bdccb6d912
  1. 14
      react/src/actions/actions/logout.js
  2. 3
      react/src/actions/storeType.js
  3. 1
      react/src/components/dashboard/navbar/navbar.js
  4. 3
      react/src/components/dashboard/sendCoin/sendCoin.js
  5. 9
      react/src/components/dashboard/walletsData/walletsData.js
  6. 12
      react/src/reducers/index.js

14
react/src/actions/actions/logout.js

@ -1,4 +1,7 @@
import { LOGIN } from '../storeType';
import {
LOGIN,
LOGOUT
} from '../storeType';
import {
triggerToaster,
Config
@ -8,7 +11,7 @@ import {
guiLogState
} from './log';
function logoutState(json, dispatch) {
function logoutState(json) {
sessionStorage.removeItem('IguanaActiveAccount');
return {
@ -17,6 +20,12 @@ function logoutState(json, dispatch) {
}
}
function logoutResetAppState() {
return {
type: LOGOUT,
}
}
export function logout() {
return dispatch => {
dispatch(walletLock());
@ -68,6 +77,7 @@ function walletLock() {
'response': json,
}));
dispatch(logoutState(json));
dispatch(logoutResetAppState());
})
}
}

3
react/src/actions/storeType.js

@ -42,4 +42,5 @@ export const SERVICE_ERROR = 'SERVICE_ERROR';
export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS';
export const LOAD_APP_INFO = 'LOAD_APP_INFO';
export const LOG_GUI_HTTP = 'LOG_GUI_HTTP';
export const CLI = 'CLI';
export const CLI = 'CLI';
export const LOGOUT = 'LOGOUT';

1
react/src/components/dashboard/navbar/navbar.js

@ -81,6 +81,7 @@ class Navbar extends React.Component {
)
);
Store.dispatch(logout());
location.reload();
}
openSyncOnlyModal() {

3
react/src/components/dashboard/sendCoin/sendCoin.js

@ -94,7 +94,8 @@ class SendCoin extends React.Component {
}
componentWillReceiveProps(props) {
if (!this.state.sendFrom &&
if (this.state &&
!this.state.sendFrom &&
this.props.ActiveCoin.activeAddress) {
this.setState(Object.assign({}, this.state, {
sendFrom: this.props.ActiveCoin.activeAddress,

9
react/src/components/dashboard/walletsData/walletsData.js

@ -351,16 +351,21 @@ class WalletsData extends React.Component {
}
}
// TODO: add basilisk first run check, display no data if second run
renderTxHistoryList() {
if (this.state.itemsList === 'loading') {
if (!this.isNativeMode() || this.isFullySynced()) {
return (
<div>{ translate('INDEX.LOADING_HISTORY') }...</div>
<tr>
<td>{ translate('INDEX.LOADING_HISTORY') }...</td>
</tr>
);
}
} else if (this.state.itemsList === 'no data') {
return (
<div>{ translate('INDEX.NO_DATA') }</div>
<tr>
<td>{ translate('INDEX.NO_DATA') }</td>
</tr>
);
} else {
if (this.state.itemsList &&

12
react/src/reducers/index.js

@ -12,7 +12,7 @@ import { Interval } from './interval';
import { SyncOnly } from './syncOnly';
import { Errors } from './errors';
const rootReducer = combineReducers({
const appReducer = combineReducers({
AddCoin,
toaster,
Main,
@ -26,4 +26,14 @@ const rootReducer = combineReducers({
routing: routerReducer,
});
// reset app state on logout
const initialState = appReducer({}, {});
const rootReducer = (state, action) => {
if (action.type === 'LOGOUT') {
state = initialState;
}
return appReducer(state, action);
}
export default rootReducer;

Loading…
Cancel
Save