mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-06 10:39:45 +00:00
only sign user out during sign in flow on the password prompt
This commit is contained in:
parent
46a0c99256
commit
0ad4adceca
4 changed files with 20 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectBalance, formatCredits } from 'lbry-redux';
|
import { selectBalance, formatCredits } from 'lbry-redux';
|
||||||
import { selectUserVerifiedEmail } from 'lbryinc';
|
import { selectUserVerifiedEmail, selectGetSyncErrorMessage } from 'lbryinc';
|
||||||
import { doSetClientSetting } from 'redux/actions/settings';
|
import { doSetClientSetting } from 'redux/actions/settings';
|
||||||
import { doSignOut } from 'redux/actions/app';
|
import { doSignOut } from 'redux/actions/app';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
|
@ -15,6 +15,7 @@ const select = state => ({
|
||||||
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
|
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
|
||||||
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
||||||
email: selectUserVerifiedEmail(state),
|
email: selectUserVerifiedEmail(state),
|
||||||
|
syncError: selectGetSyncErrorMessage(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -25,6 +25,7 @@ type Props = {
|
||||||
hideBalance: boolean,
|
hideBalance: boolean,
|
||||||
email: ?string,
|
email: ?string,
|
||||||
authHeader: boolean,
|
authHeader: boolean,
|
||||||
|
syncError: ?string,
|
||||||
signOut: () => void,
|
signOut: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,9 +40,12 @@ const Header = (props: Props) => {
|
||||||
email,
|
email,
|
||||||
authHeader,
|
authHeader,
|
||||||
signOut,
|
signOut,
|
||||||
|
syncError,
|
||||||
} = props;
|
} = props;
|
||||||
const authenticated = Boolean(email);
|
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 homeButtonNavigationProps = authHeader ? authHeaderAction : { navigate: '/' };
|
||||||
const closeButtonNavigationProps = authHeader ? authHeaderAction : { onClick: () => history.goBack() };
|
const closeButtonNavigationProps = authHeader ? authHeaderAction : { onClick: () => history.goBack() };
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import { doAuthenticate, doGetSync } from 'lbryinc';
|
||||||
import { lbrySettings as config, version as appVersion } from 'package.json';
|
import { lbrySettings as config, version as appVersion } from 'package.json';
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
import { deleteCookies, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
|
import { doSignOutCleanup, deleteSavedPassword, getSavedPassword } from 'util/saved-passwords';
|
||||||
|
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
const { autoUpdater } = remote.require('electron-updater');
|
const { autoUpdater } = remote.require('electron-updater');
|
||||||
|
@ -446,7 +446,7 @@ export function doSignIn() {
|
||||||
|
|
||||||
export function doSignOut() {
|
export function doSignOut() {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
deleteCookies()
|
doSignOutCleanup()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// @if TARGET='web'
|
// @if TARGET='web'
|
||||||
window.persistor.purge();
|
window.persistor.purge();
|
||||||
|
|
|
@ -121,12 +121,22 @@ export const deleteAuthToken = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteCookies = () => {
|
export const doSignOutCleanup = () => {
|
||||||
return new Promise<*>(resolve => {
|
return new Promise<*>(resolve => {
|
||||||
deleteCookie('auth_token');
|
deleteCookie('auth_token');
|
||||||
deleteCookie('saved-password');
|
deleteCookie('saved-password');
|
||||||
|
|
||||||
|
// @if TARGET='app'
|
||||||
|
ipcRenderer.once('delete-auth-token-response', (event, success) => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
ipcRenderer.send('delete-auth-token');
|
||||||
|
// @endif;
|
||||||
|
|
||||||
|
// @if TARGET='web'
|
||||||
|
resolve();
|
||||||
|
// @endif
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const testKeychain = () => {
|
export const testKeychain = () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue