only sign user out during sign in flow on the password prompt

This commit is contained in:
Sean Yesmunt 2019-11-01 12:19:28 -04:00
parent 46a0c99256
commit 0ad4adceca
4 changed files with 20 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
import { selectBalance, formatCredits } from 'lbry-redux';
import { selectUserVerifiedEmail } from 'lbryinc';
import { selectUserVerifiedEmail, selectGetSyncErrorMessage } from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings';
import { doSignOut } from 'redux/actions/app';
import { makeSelectClientSetting } from 'redux/selectors/settings';
@ -15,6 +15,7 @@ const select = state => ({
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
email: selectUserVerifiedEmail(state),
syncError: selectGetSyncErrorMessage(state),
});
const perform = dispatch => ({

View file

@ -25,6 +25,7 @@ type Props = {
hideBalance: boolean,
email: ?string,
authHeader: boolean,
syncError: ?string,
signOut: () => void,
};
@ -39,9 +40,12 @@ const Header = (props: Props) => {
email,
authHeader,
signOut,
syncError,
} = props;
const authenticated = Boolean(email);
const authHeaderAction = authenticated ? { onClick: signOut } : { navigate: '/' };
// Sign out if they click the "x" when they are on the password prompt
const authHeaderAction = syncError ? { onClick: signOut } : { navigate: '/' };
const homeButtonNavigationProps = authHeader ? authHeaderAction : { navigate: '/' };
const closeButtonNavigationProps = authHeader ? authHeaderAction : { onClick: () => history.goBack() };

View file

@ -38,7 +38,7 @@ import { doAuthenticate, doGetSync } from 'lbryinc';
import { lbrySettings as config, version as appVersion } from 'package.json';
import { push } from 'connected-react-router';
import analytics from 'analytics';
import { deleteCookies, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
import { doSignOutCleanup, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
// @if TARGET='app'
const { autoUpdater } = remote.require('electron-updater');
@ -446,7 +446,7 @@ export function doSignIn() {
export function doSignOut() {
return dispatch => {
deleteCookies()
doSignOutCleanup()
.then(() => {
// @if TARGET='web'
window.persistor.purge();

View file

@ -121,11 +121,21 @@ export const deleteAuthToken = () => {
});
};
export const deleteCookies = () => {
export const doSignOutCleanup = () => {
return new Promise<*>(resolve => {
deleteCookie('auth_token');
deleteCookie('saved-password');
// @if TARGET='app'
ipcRenderer.once('delete-auth-token-response', (event, success) => {
resolve();
});
ipcRenderer.send('delete-auth-token');
// @endif;
// @if TARGET='web'
resolve();
// @endif
});
};