cleanup
This commit is contained in:
parent
939a7d7689
commit
5c906df371
5 changed files with 34 additions and 50 deletions
|
@ -318,14 +318,9 @@ ipcMain.on('version-info-requested', () => {
|
|||
|
||||
requestLatestRelease();
|
||||
});
|
||||
|
||||
// In a few months, we can remove the keytar dependency and below calls once
|
||||
// enough users have moved over to cookies
|
||||
ipcMain.on('get-auth-token', event => {
|
||||
keytar.getPassword('LBRY', 'auth_token').then(token => {
|
||||
event.sender.send('auth-token-response', token ? token.toString().trim() : null);
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('delete-auth-token', (event, password) => {
|
||||
keytar.deletePassword('LBRY', 'auth_token', password).then(res => {
|
||||
event.sender.send('delete-auth-token-response', res);
|
||||
|
@ -338,14 +333,6 @@ ipcMain.on('get-password', event => {
|
|||
});
|
||||
});
|
||||
|
||||
ipcMain.on('set-password', (event, password) => {
|
||||
if (password || password === '') {
|
||||
keytar.setPassword('LBRY', 'wallet_password', password).then(res => {
|
||||
event.sender.send('set-password-response', res);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('delete-password', event => {
|
||||
keytar.deletePassword('LBRY', 'wallet_password').then(res => {
|
||||
event.sender.send('delete-password-response', res);
|
||||
|
|
18
ui/index.jsx
18
ui/index.jsx
|
@ -108,7 +108,6 @@ Lbryio.setOverride(
|
|||
|
||||
authToken = response.auth_token;
|
||||
setAuthToken(authToken);
|
||||
|
||||
resolve(authToken);
|
||||
});
|
||||
})
|
||||
|
@ -118,23 +117,6 @@ Lbryio.setOverride(
|
|||
'getAuthToken',
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
// @if TARGET='app'
|
||||
// NEED TO DO SOMETHING HERE TO CHECK FOR A COOKIE AUTH TOKEN.
|
||||
// IF IT EXISTS, SKIP AND CONTINUE BELOW THE @ENDIF
|
||||
// IF NOT, COPY THE KEYTAR AUTH TOKEN AND PASSWORD TO THE COOKIE (SetAuthToken/SetPassword?)
|
||||
// AND THEN DELETE KEYTAR ONE (Or leave for now?)
|
||||
if (authToken) {
|
||||
resolve(authToken);
|
||||
}
|
||||
|
||||
ipcRenderer.once('auth-token-response', (event, token) => {
|
||||
Lbryio.authToken = token;
|
||||
resolve(token);
|
||||
});
|
||||
|
||||
ipcRenderer.send('get-auth-token');
|
||||
// @endif
|
||||
|
||||
const authTokenToReturn = authToken || getAuthToken();
|
||||
|
||||
if (authTokenToReturn !== null) {
|
||||
|
|
|
@ -35,9 +35,7 @@ class ModalDownloading extends React.PureComponent<Props> {
|
|||
<p>{__('After the install is complete, please reopen the app.')}</p>
|
||||
<p>
|
||||
{__('Note: You can also install the AppImage version for streamlined updates.')}{' '}
|
||||
<span style={{ whiteSpace: 'nowrap' }}>
|
||||
<Button button="link" label={__('Download here.')} href="https://lbry.com/get/lbry.AppImage" />
|
||||
</span>
|
||||
<Button button="link" label={__('Download here.')} href="https://lbry.com/get/lbry.AppImage" />
|
||||
</p>
|
||||
</React.Fragment>
|
||||
) : null}
|
||||
|
|
|
@ -6,11 +6,11 @@ const isProduction = process.env.NODE_ENV === 'production';
|
|||
const maxExpiration = 2147483647;
|
||||
let sessionPassword;
|
||||
|
||||
function setCookie(name: string, value: string, days: number) {
|
||||
function setCookie(name: string, value: string, expirationDaysOnWeb: number) {
|
||||
let expires = '';
|
||||
if (days) {
|
||||
if (expirationDaysOnWeb) {
|
||||
let date = new Date();
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
date.setTime(date.getTime() + expirationDaysOnWeb * 24 * 60 * 60 * 1000);
|
||||
// If on PC, set to not expire (max)
|
||||
expires = `expires=${IS_WEB ? date.toUTCString() : maxExpiration};`;
|
||||
}
|
||||
|
@ -76,20 +76,32 @@ export const getSavedPassword = () => {
|
|||
|
||||
export const getKeychainPassword = () => {
|
||||
return new Promise<*>(resolve => {
|
||||
const password = getCookie('saved-password');
|
||||
if (password) {
|
||||
resolve(password);
|
||||
}
|
||||
// We can remove this when we remove keytar
|
||||
else {
|
||||
ipcRenderer.once('get-password-response', (event, password) => {
|
||||
resolve(password);
|
||||
});
|
||||
ipcRenderer.send('get-password');
|
||||
}
|
||||
let password;
|
||||
// @if TARGET='web'
|
||||
// In the future, this will be the only code in this function
|
||||
// Handling keytar stuff separately so we can easily rip it out later
|
||||
password = getCookie('saved-password');
|
||||
resolve(password);
|
||||
// @endif
|
||||
|
||||
// @if TARGET='app'
|
||||
password = getCookie('saved-password');
|
||||
|
||||
if (password) {
|
||||
resolve(password);
|
||||
} else {
|
||||
// No password saved in a cookie, get it from the keychain, then delete the value in the keychain
|
||||
ipcRenderer.once('get-password-response', (event, keychainPassword) => {
|
||||
resolve(keychainPassword);
|
||||
|
||||
if (keychainPassword) {
|
||||
setSavedPassword(keychainPassword, true);
|
||||
ipcRenderer.send('delete-password');
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.send('get-password');
|
||||
}
|
||||
// @endif
|
||||
});
|
||||
};
|
||||
|
@ -121,6 +133,11 @@ export const doSignOutCleanup = () => {
|
|||
deleteCookie('auth_token');
|
||||
deleteCookie('saved-password');
|
||||
resolve();
|
||||
|
||||
// @if TARGET='app'
|
||||
ipcRenderer.send('delete-auth-token');
|
||||
ipcRenderer.send('delete-password');
|
||||
// @endif;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue