1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 07:48:48 -05:00

cleanup verification constants

This commit is contained in:
Tankred Hase 2013-11-17 13:34:57 +01:00
parent c87995ee48
commit 6ed6ffdc20
2 changed files with 10 additions and 16 deletions

View File

@ -29,7 +29,8 @@ define([], function() {
} }
}, },
checkOutboxInterval: 30000, checkOutboxInterval: 30000,
iconPath: '/img/icon.png' iconPath: '/img/icon.png',
verificationUrl: '/verify/'
}; };
/** /**
@ -41,16 +42,8 @@ define([], function() {
cryptPrefix: '-----BEGIN PGP MESSAGE-----', cryptPrefix: '-----BEGIN PGP MESSAGE-----',
cryptSuffix: '-----END PGP MESSAGE-----', cryptSuffix: '-----END PGP MESSAGE-----',
signature: 'Sent securely from whiteout mail', signature: 'Sent securely from whiteout mail',
webSite: 'http://whiteout.io' webSite: 'http://whiteout.io',
}; verificationSubject: 'New public key uploaded'
/**
* Contants are maintained here.
*/
app.constants = {
verificationSubject: 'New public key uploaded',
verificationUrlPrefix: 'https://keys.whiteout.io/verify/',
verificationUuidLength: 36
}; };
return app; return app;

View File

@ -4,7 +4,7 @@ define(function(require) {
var _ = require('underscore'), var _ = require('underscore'),
util = require('cryptoLib/util'), util = require('cryptoLib/util'),
str = require('js/app-config').string, 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 * A high-level Data-Access Api for handling Email synchronization
@ -269,7 +269,7 @@ define(function(require) {
} }
function isVerificationMail(email) { function isVerificationMail(email) {
return email.subject === consts.verificationSubject; return email.subject === str.verificationSubject;
} }
function parseMessageBlock(email) { function parseMessageBlock(email) {
@ -307,7 +307,8 @@ define(function(require) {
} }
function verify(email, localCallback) { function verify(email, localCallback) {
var uuid, index; var uuid, index,
verifiyUrlPrefix = config.cloudUrl + config.verificationUrl;
if (!email.unread) { if (!email.unread) {
// don't bother if the email was already marked as read // don't bother if the email was already marked as read
@ -315,13 +316,13 @@ define(function(require) {
return; return;
} }
index = email.body.indexOf(consts.verificationUrlPrefix); index = email.body.indexOf(verifiyUrlPrefix);
if (index === -1) { if (index === -1) {
localCallback(); localCallback();
return; return;
} }
uuid = email.body.substr(index + consts.verificationUrlPrefix.length, consts.verificationUuidLength); uuid = email.body.split(config.verificationUrl)[1];
self._keychain.verifyPublicKey(uuid, function(err) { self._keychain.verifyPublicKey(uuid, function(err) {
if (err) { if (err) {
callback({ callback({