modev wallet validation from all controllers to router

This commit is contained in:
Mario Colque 2014-04-18 15:22:02 -03:00
parent 5ef607201b
commit e5a4e3c25c
9 changed files with 17 additions and 37 deletions

View File

@ -2,12 +2,7 @@
angular.module('copay.backup').controller('BackupController',
function($scope, $rootScope, $location, $window, $timeout, Socket, controllerUtils) {
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
else {
controllerUtils.handleTransactionByAddress($scope);
}
controllerUtils.handleTransactionByAddress($scope);
$scope.title = 'Backup';

View File

@ -24,10 +24,6 @@ angular.module('copay.header').controller('HeaderController',
'link': '#/backup'
}];
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
$scope.isActive = function(item) {
if (item.link && item.link.replace('#','') == $location.path()) {
return true;

View File

@ -28,9 +28,5 @@ angular.module('copay.home').controller('HomeController',
$scope.selectedAddr = addr;
};
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
_updateBalance();
});

View File

@ -7,11 +7,6 @@ angular.module('copay.peer').controller('PeerController',
//Network.connect($rootScope.masterId);
};
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
else {
controllerUtils.handleTransactionByAddress($scope);
}
controllerUtils.handleTransactionByAddress($scope);
});

View File

@ -4,12 +4,7 @@ angular.module('copay.send').controller('SendController',
function($scope, $rootScope, $location, Socket, controllerUtils) {
$scope.title = 'Send';
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
else {
controllerUtils.handleTransactionByAddress($scope);
}
controllerUtils.handleTransactionByAddress($scope);
$scope.sendTest = function() {
var w = $rootScope.wallet;

View File

@ -19,6 +19,7 @@ angular.module('copay.setup').controller('SetupController',
}
}
};
updateRCSelect($scope.totalCopayers);
$scope.$watch('totalCopayers', function(tc) {

View File

@ -1,12 +1,12 @@
'use strict';
angular.module('copay.signin').controller('SigninController',
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
// var peerData = Storage.get($rootScope.walletId, 'peerData');
// $rootScope.peerId = peerData ? peerData.peerId : null;
//
$scope.loading = false;
$scope.walletIds = walletFactory.getWalletIds();

View File

@ -34,15 +34,9 @@ angular.module('copay.transactions').controller('TransactionsController',
$scope.txs = ts;
};
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
}
else {
_updateTxs();
var socket = Socket($scope);
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
}
_updateTxs();
var socket = Socket($scope);
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
$scope.sign = function (ntxid) {
var w = $rootScope.wallet;

View File

@ -45,4 +45,12 @@ angular
$locationProvider
.html5Mode(false);
//.hashPrefix('!');
})
.run(function($rootScope, $location) {
$rootScope.$on('$routeChangeStart', function() {
if (!$rootScope.wallet || !$rootScope.wallet.id) {
console.log('############ no wallet');
$location.path('signin');
}
});
});