modev wallet validation from all controllers to router

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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