mirror of
https://github.com/moparisthebest/mail
synced 2025-02-07 02:20:14 -05:00
automatically push encrypted secret key to cloud if none exists
This commit is contained in:
parent
0d8df89dc1
commit
e5ed9c708c
@ -168,7 +168,7 @@ app.dao.CloudStorage = function(window, $) {
|
||||
keyStore = new app.dao.LocalStorageDAO(window),
|
||||
storageId = emailAddress + '_encryptedSymmetricKey',
|
||||
storedKey = keyStore.read(storageId),
|
||||
uri;
|
||||
gottenKey, uri;
|
||||
|
||||
uri = app.config.cloudUrl + '/secretkey/user/' + emailAddress;
|
||||
$.ajax({
|
||||
@ -176,7 +176,7 @@ app.dao.CloudStorage = function(window, $) {
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(keys) {
|
||||
if (!keys || keys.length === 0) {
|
||||
if (!keys) {
|
||||
callback({
|
||||
error: 'err',
|
||||
status: 'Key not synced!'
|
||||
@ -184,7 +184,12 @@ app.dao.CloudStorage = function(window, $) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleKey(keys[0], callback);
|
||||
// use first key, if it exists
|
||||
if (keys.length > 0) {
|
||||
gottenKey = keys[0];
|
||||
}
|
||||
|
||||
handleKey(gottenKey, callback);
|
||||
},
|
||||
error: function(xhr, textStatus, err) {
|
||||
callback({
|
||||
@ -200,6 +205,10 @@ app.dao.CloudStorage = function(window, $) {
|
||||
keyStore.persist(storageId, fetchedKey);
|
||||
replaceCallback();
|
||||
|
||||
} else if (!fetchedKey && storedKey && storedKey.encryptedKey && storedKey.keyIV) {
|
||||
// no key in cloud... push local key to cloud
|
||||
self.putUserSecretKey(emailAddress, callback);
|
||||
|
||||
} else if (storedKey && fetchedKey && (storedKey.encryptedKey !== fetchedKey.encryptedKey || storedKey.keyIV !== fetchedKey.keyIV)) {
|
||||
// local and fetched keys are not equal
|
||||
if (window.confirm('Swap local key?')) {
|
||||
@ -219,7 +228,7 @@ app.dao.CloudStorage = function(window, $) {
|
||||
}
|
||||
|
||||
} else {
|
||||
// local and cloud keys are equal or cloud key is null
|
||||
// local and cloud keys are equal
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
<div id="loginForm">
|
||||
<h3>Please sign in</h3>
|
||||
<label for="userId" class="ui-hidden-accessible">Username:</label>
|
||||
<input type="email" name="user" id="userId" value="test@atlasdev.onmicrosoft.com" placeholder="email" data-theme="a">
|
||||
<input type="email" name="user" id="userId" value="integration@mail.whiteout.io" placeholder="email" data-theme="a">
|
||||
<label for="password" class="ui-hidden-accessible">Password:</label>
|
||||
<input type="password" name="pass" id="password" value="Xoza76645" placeholder="password" data-theme="a">
|
||||
<input type="password" name="pass" id="password" value="hellosafe" placeholder="password" data-theme="a">
|
||||
<input type="button" data-theme="b" data-icon="check" id="loginBtn" value="Sign in">
|
||||
</div>
|
||||
</div><!-- /content -->
|
Loading…
Reference in New Issue
Block a user