From 6ed6ffdc20ed2f6078257a7b2917bae38494248b Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Sun, 17 Nov 2013 13:34:57 +0100 Subject: [PATCH] cleanup verification constants --- src/js/app-config.js | 15 ++++----------- src/js/dao/email-dao.js | 11 ++++++----- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/js/app-config.js b/src/js/app-config.js index 39a3425..abd043c 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -29,7 +29,8 @@ define([], function() { } }, checkOutboxInterval: 30000, - iconPath: '/img/icon.png' + iconPath: '/img/icon.png', + verificationUrl: '/verify/' }; /** @@ -41,16 +42,8 @@ define([], function() { cryptPrefix: '-----BEGIN PGP MESSAGE-----', cryptSuffix: '-----END PGP MESSAGE-----', signature: 'Sent securely from whiteout mail', - webSite: 'http://whiteout.io' - }; - - /** - * Contants are maintained here. - */ - app.constants = { - verificationSubject: 'New public key uploaded', - verificationUrlPrefix: 'https://keys.whiteout.io/verify/', - verificationUuidLength: 36 + webSite: 'http://whiteout.io', + verificationSubject: 'New public key uploaded' }; return app; diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 248ce24..3b9552a 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -4,7 +4,7 @@ define(function(require) { var _ = require('underscore'), util = require('cryptoLib/util'), str = require('js/app-config').string, - consts = require('js/app-config').constants; + config = require('js/app-config').config; /** * A high-level Data-Access Api for handling Email synchronization @@ -269,7 +269,7 @@ define(function(require) { } function isVerificationMail(email) { - return email.subject === consts.verificationSubject; + return email.subject === str.verificationSubject; } function parseMessageBlock(email) { @@ -307,7 +307,8 @@ define(function(require) { } function verify(email, localCallback) { - var uuid, index; + var uuid, index, + verifiyUrlPrefix = config.cloudUrl + config.verificationUrl; if (!email.unread) { // don't bother if the email was already marked as read @@ -315,13 +316,13 @@ define(function(require) { return; } - index = email.body.indexOf(consts.verificationUrlPrefix); + index = email.body.indexOf(verifiyUrlPrefix); if (index === -1) { localCallback(); return; } - uuid = email.body.substr(index + consts.verificationUrlPrefix.length, consts.verificationUuidLength); + uuid = email.body.split(config.verificationUrl)[1]; self._keychain.verifyPublicKey(uuid, function(err) { if (err) { callback({