mirror of
https://github.com/moparisthebest/mail
synced 2025-02-16 23:20:09 -05:00
[WO-53] import key on new device
This commit is contained in:
parent
34547f7bb6
commit
36c8d1e003
@ -17,7 +17,7 @@ require([
|
||||
], function(angular, AccountCtrl, LoginCtrl, LoginInitialCtrl, LoginNewDeviceCtrl, LoginExistingCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'mail-list', 'write', 'read']);
|
||||
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'mail-list', 'write', 'read', 'login-new-device']);
|
||||
|
||||
// set router paths
|
||||
app.config(function($routeProvider) {
|
||||
|
@ -37,13 +37,19 @@ define(function(require) {
|
||||
|
||||
function download(content, filename, contentType) {
|
||||
contentType = contentType || 'application/octet-stream';
|
||||
var a = document.createElement('a');
|
||||
var blob = new Blob([content], {
|
||||
'type': contentType
|
||||
chrome.fileSystem.chooseEntry({
|
||||
type: 'saveFile',
|
||||
suggestedName: filename
|
||||
}, function(file) {
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
file.createWriter(function(writer) {
|
||||
writer.onerror = console.error;
|
||||
writer.onwriteend = function() {};
|
||||
writer.write(new Blob([content], { type: contentType }));
|
||||
}, console.error);
|
||||
});
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.download = filename;
|
||||
a.click();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,13 +1,87 @@
|
||||
define(function() {
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var LoginExistingCtrl = function($scope) {
|
||||
|
||||
var angular = require('angular'),
|
||||
appController = require('js/app-controller');
|
||||
|
||||
var LoginExistingCtrl = function($scope, $location) {
|
||||
$scope.confirmPassphrase = function() {
|
||||
window.alert('Not implemented yet!');
|
||||
var passphrase = $scope.passphrase,
|
||||
emailDao = appController._emailDao;
|
||||
|
||||
if (!passphrase) {
|
||||
return;
|
||||
}
|
||||
|
||||
unlockCrypto(imapLogin);
|
||||
|
||||
function unlockCrypto(callback) {
|
||||
var userId = emailDao._account.emailAddress;
|
||||
emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
keypair.privateKey = {
|
||||
_id: keypair.publicKey._id,
|
||||
userId: userId,
|
||||
encryptedKey: $scope.key
|
||||
};
|
||||
emailDao.unlock(keypair, passphrase, function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
emailDao._keychain.putUserKeyPair(keypair, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function imapLogin(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// login to imap backend
|
||||
appController._emailDao.imapLogin(function(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
onLogin();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function onLogin() {
|
||||
$location.path('/desktop');
|
||||
$scope.$apply();
|
||||
}
|
||||
};
|
||||
|
||||
var ngModule = angular.module('login-new-device', []);
|
||||
ngModule.directive('fileReader', function() {
|
||||
return function(scope, elm) {
|
||||
elm.bind('change', function(e) {
|
||||
var files = e.target.files,
|
||||
reader = new FileReader();
|
||||
|
||||
if (files.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
reader.onload = (function(scope) {
|
||||
return function(e) {
|
||||
scope.key = e.target.result;
|
||||
};
|
||||
})(scope);
|
||||
reader.readAsText(files[0]);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
return LoginExistingCtrl;
|
||||
});
|
@ -40,7 +40,7 @@ define(function(require) {
|
||||
|
||||
function redirect(availableKeys) {
|
||||
// redirect if needed
|
||||
if (!availableKeys.publicKey) {
|
||||
if (typeof availableKeys === 'undefined') {
|
||||
// no public key available, start onboarding process
|
||||
$location.path('/login-initial');
|
||||
} else if (!availableKeys.privateKey) {
|
||||
|
@ -19,6 +19,9 @@ define(['jquery', 'js/app-config'], function($, app) {
|
||||
url: uri,
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
success: function(res) {
|
||||
callback(null, res);
|
||||
},
|
||||
|
@ -7,7 +7,9 @@
|
||||
"icons": {
|
||||
"128": "img/icon.png"
|
||||
},
|
||||
"permissions": [
|
||||
"permissions": [{
|
||||
"fileSystem": ["write"]
|
||||
},
|
||||
"https://keys.whiteout.io/",
|
||||
"identity", {
|
||||
"socket": [
|
||||
|
@ -1 +1,18 @@
|
||||
<p>not implemented yet...</p>
|
||||
<div class="view-login">
|
||||
|
||||
<div class="logo-wrapper">
|
||||
<div class="logo"></div>
|
||||
</div><!--/logo-->
|
||||
|
||||
<div class="content">
|
||||
<h1>Import keyfile</h1>
|
||||
|
||||
<p>You are already registered on another device. To access your communication on this device, please import the encrypted key file.</p>
|
||||
|
||||
<form>
|
||||
<div><input type="file" file-reader tabindex="1"></div>
|
||||
<div><input type="password" ng-model="passphrase" placeholder="Passphrase" tabindex="2"></div>
|
||||
<div><button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!key" tabindex="3">Import</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user