mirror of https://github.com/keeweb/keeweb.git
Fixed some PR comments
This commit is contained in:
parent
12603ff2ab
commit
945a902071
|
@ -1,9 +1,10 @@
|
|||
'use strict';
|
||||
/* global FingerprintAuth */
|
||||
|
||||
const Launcher = {
|
||||
name: 'cordova',
|
||||
version: '6.0.0',
|
||||
autoTypeSupported: false,
|
||||
thirdPartyStoragesSupported: false,
|
||||
ready: function(callback) {
|
||||
document.addEventListener('deviceready', callback, false);
|
||||
},
|
||||
|
@ -158,7 +159,7 @@ const Launcher = {
|
|||
},
|
||||
showMainWindow: function() { /* skip in cordova */ },
|
||||
// spawn: function(config) { },
|
||||
openFileChooser: function(callback, button) {
|
||||
openFileChooser: function(callback) {
|
||||
const onFileSelected = function(selected) {
|
||||
window.resolveLocalFileSystemURL(selected.uri, fileEntry => {
|
||||
fileEntry.file(file => {
|
||||
|
@ -178,20 +179,19 @@ const Launcher = {
|
|||
clientId: 'keeweb'
|
||||
},
|
||||
|
||||
register: function(appModel, fileInfo, password) {
|
||||
FingerprintAuth.isAvailable(result => { // eslint-disable-line no-undef
|
||||
register: function(fileId, password, callback) {
|
||||
FingerprintAuth.isAvailable(result => {
|
||||
if (!result.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
const encryptConfig = _.extend({}, this.config, {
|
||||
username: fileInfo.id,
|
||||
password: password.getText()
|
||||
username: fileId,
|
||||
password: password
|
||||
});
|
||||
|
||||
FingerprintAuth.encrypt(encryptConfig, result => { // eslint-disable-line no-undef
|
||||
fileInfo.set('fingerprint', result.token);
|
||||
appModel.fileInfos.save();
|
||||
FingerprintAuth.encrypt(encryptConfig, result => {
|
||||
callback(result.token);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ const Launcher = {
|
|||
token: fileInfo.get('fingerprint')
|
||||
});
|
||||
|
||||
FingerprintAuth.decrypt(decryptConfig, result => { // eslint-disable-line no-undef
|
||||
FingerprintAuth.decrypt(decryptConfig, result => {
|
||||
callback(result.password);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ const Launcher = {
|
|||
name: 'electron',
|
||||
version: window.process.versions.electron,
|
||||
autoTypeSupported: true,
|
||||
thirdPartyStoragesSupported: true,
|
||||
req: window.require,
|
||||
platform: function() {
|
||||
return process.platform;
|
||||
|
@ -244,10 +245,8 @@ const Launcher = {
|
|||
}
|
||||
}
|
||||
return ps;
|
||||
},
|
||||
openFileChooser: function(callback, button) {
|
||||
button.click();
|
||||
}
|
||||
// openFileChooser: function(callback) { }
|
||||
};
|
||||
|
||||
Backbone.on('launcher-exit-request', () => {
|
||||
|
|
|
@ -550,8 +550,11 @@ const AppModel = Backbone.Model.extend({
|
|||
this.fileInfos.unshift(fileInfo);
|
||||
this.fileInfos.save();
|
||||
|
||||
if (Launcher && Launcher.fingerprints && !existing) {
|
||||
Launcher.fingerprints.register(this, fileInfo, password);
|
||||
if (Launcher && Launcher.fingerprints && !existing) { // only if file is not registered yet
|
||||
Launcher.fingerprints.register(fileInfo.id, password.getText(), token => {
|
||||
fileInfo.set('fingerprint', token);
|
||||
this.fileInfos.save();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -12,11 +12,9 @@ const ThirdPartyStorage = {
|
|||
onedrive: require('./storage-onedrive')
|
||||
};
|
||||
|
||||
let storages;
|
||||
if (Launcher.name === 'cordova') {
|
||||
let storages = _.extend(BuiltInStorage, ThirdPartyStorage);
|
||||
if (Launcher && !Launcher.thirdPartyStoragesSupported) {
|
||||
storages = BuiltInStorage;
|
||||
} else {
|
||||
storages = _.extend(BuiltInStorage, ThirdPartyStorage);
|
||||
}
|
||||
|
||||
module.exports = storages;
|
||||
|
|
|
@ -322,14 +322,14 @@ const OpenView = Backbone.View.extend({
|
|||
|
||||
const fileInput = this.$el.find('.open__file-ctrl').attr('accept', ext || '').val(null);
|
||||
|
||||
if (Launcher) {
|
||||
if (Launcher && Launcher.openFileChooser) {
|
||||
Launcher.openFileChooser((err, file) => {
|
||||
if (err) {
|
||||
logger.error('Error opening file chooser', err);
|
||||
} else {
|
||||
this.processFile(file);
|
||||
}
|
||||
}, fileInput);
|
||||
});
|
||||
} else {
|
||||
fileInput.click();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue