diff --git a/src/js/app-config.js b/src/js/app-config.js index d10da0a..0f2a6fe 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -7,6 +7,7 @@ exports.config = { cloudUrl: 'https://keys.whiteout.io', privkeyServerUrl: 'https://keychain.whiteout.io', adminUrl: 'https://admin-node.whiteout.io', + settingsUrl: 'https://settings.whiteout.io/autodiscovery/', wmailDomain: 'wmail.io', serverPrivateKeyId: 'EE342F0DDBB0F3BE', symKeySize: 256, diff --git a/src/js/controller/add-account.js b/src/js/controller/add-account.js index ccc1d17..dd5a9cd 100644 --- a/src/js/controller/add-account.js +++ b/src/js/controller/add-account.js @@ -3,89 +3,41 @@ var appCtrl = require('../app-controller'), cfg = require('../app-config').config; -var AddAccountCtrl = function($scope, $location, $routeParams) { +var AddAccountCtrl = function($scope, $location, $routeParams, $http) { if (!appCtrl._auth && !$routeParams.dev) { $location.path('/'); // init app return; } - $scope.step = 1; - - $scope.goTo = function(step) { - $scope.step = step; - }; - - $scope.createWhiteoutAccount = function() { + $scope.getAccountSettings = function() { if ($scope.form.$invalid) { return; } $scope.busy = true; $scope.errMsg = undefined; // reset error msg - $scope.emailAddress = $scope.user + '@' + cfg.wmailDomain; - // call REST api - appCtrl._adminDao.createUser({ - emailAddress: $scope.emailAddress, - password: $scope.pass, - phone: $scope.phone.replace(/\s+/g, ''), // remove spaces from the phone number - betaCode: $scope.betaCode.toUpperCase() - }, function(err) { + var domain = $scope.emailAddress.split('@')[1]; + var url = cfg.settingsUrl + domain; + + $http.get(url).success(function(config) { $scope.busy = false; + $scope.state.mailConfig = config; + $scope.state.emailAddress = $scope.emailAddress; - if (err) { - $scope.errMsg = err.errMsg || err.message; - $scope.$apply(); + // check for gmail/oauth server + var hostname = config.imap.hostname; + if (hostname.match(/.gmail.com$/) || hostname.match(/.googlemail.com$/)) { + $scope.connectToGoogle(); return; } - $scope.goTo(3); - $scope.$apply(); + }).error(function() { + $scope.busy = false; + $scope.errMsg = 'Error getting IMAP settings for that email address!'; }); }; - $scope.validateUser = function() { - if ($scope.formValidate.$invalid) { - return; - } - - $scope.busyValidate = true; - $scope.errMsgValidate = undefined; // reset error msg - - // verify user to REST api - appCtrl._adminDao.validateUser({ - emailAddress: $scope.emailAddress, - token: $scope.token.toUpperCase() - }, function(err) { - if (err) { - $scope.busyValidate = false; - $scope.errMsgValidate = err.errMsg || err.message; - $scope.$apply(); - return; - } - - // proceed to login - $scope.login(); - }); - }; - - $scope.login = function() { - // store credentials in memory - appCtrl._auth.setCredentials({ - provider: 'wmail', - emailAddress: $scope.emailAddress, - username: $scope.emailAddress, - realname: $scope.realname, - password: $scope.pass, - imap: cfg.wmail.imap, - smtp: cfg.wmail.smtp - }); - - // proceed to login and keygen - $location.path('/login'); - $scope.$apply(); - }; - $scope.connectToGoogle = function() { // test for oauth support if (appCtrl._auth._oauth.isSupported()) { diff --git a/src/js/controller/create-account.js b/src/js/controller/create-account.js new file mode 100644 index 0000000..57f7155 --- /dev/null +++ b/src/js/controller/create-account.js @@ -0,0 +1,43 @@ +'use strict'; + +var appCtrl = require('../app-controller'), + cfg = require('../app-config').config; + +var CreateAccountCtrl = function($scope, $location, $routeParams) { + if (!appCtrl._auth && !$routeParams.dev) { + $location.path('/'); // init app + return; + } + + $scope.createWhiteoutAccount = function() { + if ($scope.form.$invalid) { + return; + } + + $scope.busy = true; + $scope.errMsg = undefined; // reset error msg + $scope.emailAddress = $scope.user + '@' + cfg.wmailDomain; + + // call REST api + appCtrl._adminDao.createUser({ + emailAddress: $scope.emailAddress, + password: $scope.pass, + phone: $scope.phone.replace(/\s+/g, ''), // remove spaces from the phone number + betaCode: $scope.betaCode.toUpperCase() + }, function(err) { + $scope.busy = false; + + if (err) { + $scope.errMsg = err.errMsg || err.message; + $scope.$apply(); + return; + } + + // proceed to login and keygen + $location.path('/validate-phone'); + $scope.$apply(); + }); + }; +}; + +module.exports = CreateAccountCtrl; \ No newline at end of file diff --git a/src/js/controller/login-set-credentials.js b/src/js/controller/login-set-credentials.js index 74bbe0b..9a208ab 100644 --- a/src/js/controller/login-set-credentials.js +++ b/src/js/controller/login-set-credentials.js @@ -27,6 +27,8 @@ var SetCredentialsCtrl = function($scope, $location, $routeParams) { if ($scope.useOAuth) { $scope.emailAddress = auth.emailAddress; + } else if ($scope.state.emailAddress) { + $scope.emailAddress = $scope.state.emailAddress; } if ($scope.hasProviderPreset) { diff --git a/src/js/controller/validate-phone.js b/src/js/controller/validate-phone.js new file mode 100644 index 0000000..e793c27 --- /dev/null +++ b/src/js/controller/validate-phone.js @@ -0,0 +1,55 @@ +'use strict'; + +var appCtrl = require('../app-controller'), + cfg = require('../app-config').config; + +var ValidatePhoneCtrl = function($scope, $location, $routeParams) { + if (!appCtrl._auth && !$routeParams.dev) { + $location.path('/'); // init app + return; + } + + $scope.validateUser = function() { + if ($scope.formValidate.$invalid) { + return; + } + + $scope.busyValidate = true; + $scope.errMsgValidate = undefined; // reset error msg + + // verify user to REST api + appCtrl._adminDao.validateUser({ + emailAddress: $scope.emailAddress, + token: $scope.token.toUpperCase() + }, function(err) { + if (err) { + $scope.busyValidate = false; + $scope.errMsgValidate = err.errMsg || err.message; + $scope.$apply(); + return; + } + + // proceed to login + $scope.login(); + }); + }; + + $scope.login = function() { + // store credentials in memory + appCtrl._auth.setCredentials({ + provider: 'wmail', + emailAddress: $scope.emailAddress, + username: $scope.emailAddress, + realname: $scope.realname, + password: $scope.pass, + imap: cfg.wmail.imap, + smtp: cfg.wmail.smtp + }); + + // proceed to login and keygen + $location.path('/login'); + $scope.$apply(); + }; +}; + +module.exports = ValidatePhoneCtrl; \ No newline at end of file diff --git a/src/tpl/add-account.html b/src/tpl/add-account.html index 93d4563..345f263 100644 --- a/src/tpl/add-account.html +++ b/src/tpl/add-account.html @@ -4,23 +4,25 @@ whiteout.io
-

Connect your email account

-

Enter your email to connect with whiteout.

+

Connect email account

+

Connect the Whiteout Mail client to your existing email account via IMAP for easy to use end-to-end encryption. We cannot read your password or messages. Learn more

+

{{errMsg}}

Please fill out all required fields!

- +
- +
+

- Or create a new fully encrypted whiteout mailbox. + Or sign up for a new fully encrypted Whiteout Mailbox.

diff --git a/src/tpl/login-set-credentials.html b/src/tpl/login-set-credentials.html index 14dc25b..1a1695c 100644 --- a/src/tpl/login-set-credentials.html +++ b/src/tpl/login-set-credentials.html @@ -6,14 +6,10 @@

Login

- Please enter your email address and password. - The password is used to authenticate directly - with your mail provider and is not sent to our servers. + Please enter your email address and password. The password is used to authenticate with your mail provider over an encrypted connection. We cannot read your password. Learn more

- Please confirm your email address. Your account will - authenticate directly with your mail provider. Your - credentials are never sent to our servers. + Please confirm your email address. Your account will authenticate with your mail provider over an encrypted connection. Learn more

diff --git a/src/tpl/page-footer.html b/src/tpl/page-footer.html index 9787f55..144aac4 100644 --- a/src/tpl/page-footer.html +++ b/src/tpl/page-footer.html @@ -1,12 +1,12 @@ -