Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Merge 1ab336d into 0243722
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Jan 15, 2016
2 parents 0243722 + 1ab336d commit ed68e1e
Show file tree
Hide file tree
Showing 17 changed files with 360 additions and 242 deletions.
2 changes: 2 additions & 0 deletions app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ head
script(src='build/js/core/myWallet.service.js')
script(src='build/js/core/payment.service.js')
script(src='build/js/core/walletTokenEndpoints.service.js')
script(src='build/js/core/walletNetwork.service.js')

script(src='build/js/browser-polyfill.js')
script(src='build/js/app.js')
Expand Down Expand Up @@ -153,6 +154,7 @@ head
script(src='build/js/directives/destinationInput.directive.js')

script(src='build/js/services/wallet.service.js')
script(src='build/js/services/walletNetwork.service.js')
script(src='build/js/services/securityCenter.service.js')
script(src='build/js/services/adverts.service.js')
script(src='build/js/services/bcTranslationLoader.service.js')
Expand Down
29 changes: 12 additions & 17 deletions assets/js/controllers/authorizeApprove.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@ angular
.module('walletApp')
.controller("AuthorizeApproveCtrl", AuthorizeApproveCtrl);

function AuthorizeApproveCtrl($window, $scope, Wallet, $stateParams, $state, Alerts, $translate) {
const success = (uid) => {
function AuthorizeApproveCtrl($window, $scope, WalletNetwork, $stateParams, $state, Alerts, $translate) {
const success = (res) => {
$scope.checkingToken = false;
$scope.busyApproving = false;
$scope.busyRejecting = false;

// If differentBrowser is called, success will be null:
if (res.success == null) return;

$window.close(); // This is sometimes ignored, hence the code below:

if(uid) {
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-uid", {uid: uid}).then(() => {
Alerts.displaySuccess(translation)
});
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-uid", {uid: res.guid}).then(() => {
Alerts.displaySuccess(translation)
});
} else {
$translate('AUTHORIZE_APPROVE_SUCCESS').then(translation => {
$state.go("public.login-no-uid").then(() => {
Alerts.displaySuccess(translation)
});
});
}
});

}

const error = (message) => {
Expand All @@ -44,13 +39,13 @@ function AuthorizeApproveCtrl($window, $scope, Wallet, $stateParams, $state, Ale

$scope.checkingToken = true;

Wallet.authorizeApprove($stateParams.token, differentBrowser, null)
WalletNetwork.authorizeApprove($stateParams.token, differentBrowser, null)
.then(success)
.catch(error);

$scope.approve = () => {
$scope.busyApproving = true;
Wallet.authorizeApprove($stateParams.token, () => {}, true)
WalletNetwork.authorizeApprove($stateParams.token, () => {}, true)
.then(success)
.catch(error);
}
Expand All @@ -68,7 +63,7 @@ function AuthorizeApproveCtrl($window, $scope, Wallet, $stateParams, $state, Ale
});
};

Wallet.authorizeApprove($stateParams.token, () => {}, false)
WalletNetwork.authorizeApprove($stateParams.token, () => {}, false)
.then(rejected)
.catch(error);
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/controllers/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular
.module('walletApp')
.controller("LoginCtrl", LoginCtrl);

function LoginCtrl($scope, $rootScope, $log, $http, Wallet, Alerts, $cookies, $uibModal, $state, $stateParams, $timeout, $translate, filterFilter) {
function LoginCtrl($scope, $rootScope, $log, $http, Wallet, WalletNetwork, Alerts, $cookies, $uibModal, $state, $stateParams, $timeout, $translate, filterFilter) {
$scope.status = Wallet.status;
$scope.settings = Wallet.settings;
$scope.disableLogin = null;
Expand Down Expand Up @@ -136,7 +136,7 @@ function LoginCtrl($scope, $rootScope, $log, $http, Wallet, Alerts, $cookies, $u
const error = () => {
$scope.resending = false;
};
Wallet.resendTwoFactorSms($scope.uid, success, error);
WalletNetwork.resendTwoFactorSms($scope.uid).then(success).catch(error);
}
};

Expand Down
4 changes: 2 additions & 2 deletions assets/js/controllers/lostGuid.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular
.module('walletApp')
.controller('LostGuidCtrl', LostGuidCtrl);

function LostGuidCtrl($scope, $rootScope, $http, $translate, Wallet, Alerts) {
function LostGuidCtrl($scope, $rootScope, $http, $translate, WalletNetwork, Alerts) {
$scope.currentStep = 1;
$scope.fields = {
email: '',
Expand All @@ -29,7 +29,7 @@ function LostGuidCtrl($scope, $rootScope, $http, $translate, Wallet, Alerts) {
$scope.remindForm.$setPristine();
$scope.remindForm.$setUntouched();

Wallet.recoverGuid($scope.fields.email, $scope.fields.captcha).then(success).catch(error);
WalletNetwork.recoverGuid($scope.fields.email, $scope.fields.captcha).then(success).catch(error);
};

// Set SID cookie by requesting headers
Expand Down
4 changes: 2 additions & 2 deletions assets/js/controllers/resetTwoFactor.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular
.module('walletApp')
.controller('ResetTwoFactorCtrl', ResetTwoFactorCtrl);

function ResetTwoFactorCtrl($scope, $rootScope, $http, $translate, Wallet, Alerts) {
function ResetTwoFactorCtrl($scope, $rootScope, $http, $translate, WalletNetwork, Alerts) {

$scope.currentStep = 1;
$scope.fields = {
Expand Down Expand Up @@ -34,7 +34,7 @@ function ResetTwoFactorCtrl($scope, $rootScope, $http, $translate, Wallet, Alert
$scope.form.$setPristine();
$scope.form.$setUntouched();

Wallet.requestTwoFactorReset(
WalletNetwork.requestTwoFactorReset(
$scope.fields.uid,
$scope.fields.email,
$scope.fields.newEmail,
Expand Down
4 changes: 2 additions & 2 deletions assets/js/controllers/resetTwoFactorToken.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular
.module('walletApp')
.controller("ResetTwoFactorTokenCtrl", ResetTwoFactorTokenCtrl);

function ResetTwoFactorTokenCtrl($scope, Wallet, $stateParams, $state, Alerts, $translate, $rootScope) {
function ResetTwoFactorTokenCtrl($scope, WalletNetwork, $stateParams, $state, Alerts, $translate, $rootScope) {
const success = (obj) => {

$scope.checkingToken = false
Expand All @@ -27,5 +27,5 @@ function ResetTwoFactorTokenCtrl($scope, Wallet, $stateParams, $state, Alerts, $

$scope.checkingToken = true

Wallet.resetTwoFactorToken($stateParams.token).then(success).catch(error);
WalletNetwork.resetTwoFactorToken($stateParams.token).then(success).catch(error);
}
4 changes: 2 additions & 2 deletions assets/js/controllers/unsubscribe.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular
.module('walletApp')
.controller("UnsubscribeCtrl", UnsubscribeCtrl);

function UnsubscribeCtrl($scope, Wallet, $stateParams, $state, Alerts, $translate) {
function UnsubscribeCtrl($scope, WalletNetwork, $stateParams, $state, Alerts, $translate) {
const success = (uid) => {

if(uid) {
Expand All @@ -27,5 +27,5 @@ function UnsubscribeCtrl($scope, Wallet, $stateParams, $state, Alerts, $translat
Alerts.displayError(message, true);
}

Wallet.unsubscribe($stateParams.token).then(success).catch(error);
WalletNetwork.unsubscribe($stateParams.token).then(success).catch(error);
}
32 changes: 6 additions & 26 deletions assets/js/controllers/verifyEmail.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,19 @@ angular
.module('walletApp')
.controller("VerifyEmailCtrl", VerifyEmailCtrl);

function VerifyEmailCtrl($scope, Wallet, $stateParams, $state, Alerts, $translate, $rootScope) {
function VerifyEmailCtrl($scope, WalletNetwork, $stateParams, $state, Alerts, $translate, $rootScope) {
const success = (uid) => {
if(uid) {
$translate(['SUCCESS', 'EMAIL_VERIFIED_SUCCESS']).then(translations => {
$state.go("public.login-uid", {uid: uid}).then(() =>{
$rootScope.$emit('showNotification', {
type: 'verified-email',
icon: 'ti-email',
heading: translations.SUCCESS,
msg: translations.EMAIL_VERIFIED_SUCCESS
});
});
$translate(['SUCCESS', 'EMAIL_VERIFIED_SUCCESS']).then(translations => {
$state.go("public.login-uid", {uid: uid}).then(() =>{
Alerts.displayVerifiedEmail()
});
} else {
$translate(['SUCCESS', 'EMAIL_VERIFIED_SUCCESS_NO_UID']).then(translations => {
$state.go("public.login-no-uid").then(() => {
$rootScope.$emit('showNotification', {
type: 'verified-email',
icon: 'ti-email',
heading: translations.SUCCESS,
msg: translations.EMAIL_VERIFIED_SUCCESS_NO_UID
});
});
});
}


});
}

const error = (message) => {
$state.go("public.login-no-uid");
Alerts.displayError(message, true);
}

Wallet.verifyEmail($stateParams.token).then(success).catch(error);
WalletNetwork.verifyEmail($stateParams.token).then(success).catch(error);
}
7 changes: 7 additions & 0 deletions assets/js/core/walletNetwork.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
angular
.module('walletApp.core')
.factory('MyWalletNetwork', MyWalletNetwork);

function MyWalletNetwork() {
return Blockchain.WalletNetwork
}
16 changes: 13 additions & 3 deletions assets/js/services/alerts.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ angular
.module('walletApp')
.factory('Alerts', Alerts);

Alerts.$inject = ['$timeout'];
Alerts.$inject = ['$timeout', '$rootScope'];

function Alerts($timeout) {
function Alerts($timeout, $rootScope) {
const service = {
alerts : [],
close : close,
Expand All @@ -13,7 +13,8 @@ function Alerts($timeout) {
displaySuccess : display.bind(null, 'success'),
displayWarning : display.bind(null, ''),
displayError : display.bind(null, 'danger'),
displayReceivedBitcoin : display.bind(null, 'received-bitcoin')
displayReceivedBitcoin : display.bind(null, 'received-bitcoin'),
displayVerifiedEmail : displayVerifiedEmail
};

function close(alert, context=service.alerts) {
Expand All @@ -34,5 +35,14 @@ function Alerts($timeout) {
context.push(alert);
}

function displayVerifiedEmail() {
$rootScope.$emit('showNotification', {
type: 'verified-email',
icon: 'ti-email',
heading: translations.SUCCESS,
msg: translations.EMAIL_VERIFIED_SUCCESS
});
}

return service;
}
Loading

0 comments on commit ed68e1e

Please sign in to comment.