mirror of https://github.com/keeweb/keeweb.git
fix #35: Dropbox notification in self-hosted apps
This commit is contained in:
parent
dd1c82e1e2
commit
2d9f27f852
|
@ -2,12 +2,24 @@
|
|||
|
||||
var Dropbox = require('dropbox'),
|
||||
Alerts = require('./alerts'),
|
||||
Launcher = require('./launcher');
|
||||
Launcher = require('./launcher'),
|
||||
Links = require('../const/links');
|
||||
|
||||
var DropboxKeys = {
|
||||
AppFolder: 'qp7ctun6qt5n9d6'
|
||||
AppFolder: 'qp7ctun6qt5n9d6',
|
||||
AppFolderKeyParts: ['qp7ctun6', 'qt5n9d6'] // to allow replace key by sed, compare in this way
|
||||
};
|
||||
|
||||
var DropboxCustomErrors = {
|
||||
BadKey: 'bad-key'
|
||||
};
|
||||
|
||||
function isValidKey() {
|
||||
var isSelfHostedApp = !/^http(s?):\/\/localhost:8085/.test(location.href) &&
|
||||
!/http(s?):\/\/antelle\.github\.io\/keeweb/.test(location.href);
|
||||
return Launcher || !isSelfHostedApp || DropboxKeys.AppFolder !== DropboxKeys.AppFolderKeyParts.join('');
|
||||
}
|
||||
|
||||
var DropboxChooser = function(callback) {
|
||||
this.cb = callback;
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
|
@ -114,6 +126,15 @@ var DropboxLink = {
|
|||
complete(null, this._dropboxClient);
|
||||
return;
|
||||
}
|
||||
if (!isValidKey()) {
|
||||
Alerts.error({
|
||||
icon: 'dropbox',
|
||||
header: 'Dropbox not configured',
|
||||
body: 'So, you are using KeeWeb on your own server? Good!<br/>' +
|
||||
'<a href="' + Links.SelfHostedDropbox + '" target="blank">Some configuration</a> is required to make Dropbox work, it\'s just 3 steps away.'
|
||||
});
|
||||
return complete(DropboxCustomErrors.BadKey);
|
||||
}
|
||||
var client = new Dropbox.Client({key: DropboxKeys.AppFolder});
|
||||
if (Launcher) {
|
||||
client.authDriver(new Dropbox.AuthDriver.Electron({ receiverUrl: location.href }));
|
||||
|
|
|
@ -6,7 +6,8 @@ var Links = {
|
|||
WebApp: 'https://antelle.github.io/keeweb/',
|
||||
License: 'https://github.com/antelle/keeweb/blob/master/MIT-LICENSE.txt',
|
||||
UpdateDesktop: 'https://github.com/antelle/keeweb/releases/download/{ver}/UpdateDesktop.zip',
|
||||
ReleaseNotes: 'https://github.com/antelle/keeweb/blob/master/release-notes.md#release-notes'
|
||||
ReleaseNotes: 'https://github.com/antelle/keeweb/blob/master/release-notes.md#release-notes',
|
||||
SelfHostedDropbox: 'https://github.com/antelle/keeweb#self-hosting'
|
||||
};
|
||||
|
||||
module.exports = Links;
|
||||
|
|
|
@ -4,6 +4,7 @@ Release notes
|
|||
Bugfixes
|
||||
`-` fixed tag list scrolling
|
||||
`+` desktop Dropbox
|
||||
`+` Dropbox notification in self-hosted apps
|
||||
|
||||
##### v0.3.0 (2015-11-14)
|
||||
Auto-update
|
||||
|
|
Loading…
Reference in New Issue