Wallet/js/controllers/home.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2014-10-01 08:35:17 -03:00
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager) {
2014-09-03 01:25:08 -03:00
controllerUtils.redirIfLogged();
$scope.retreiving =true;
copay.Identity.anyProfile({
pluginManager: pluginManager,
}, function(any) {
$scope.retreiving =false;
if (!any)
$location.path('/createProfile');
});
2014-10-01 08:35:17 -03:00
$scope.openProfile = function(form) {
2014-10-09 18:53:31 -03:00
if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields');
return;
}
2014-10-01 08:35:17 -03:00
$scope.loading = true;
copay.Identity.open(form.email.$modelValue, form.password.$modelValue, {
pluginManager: pluginManager,
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
2014-10-11 14:33:45 -03:00
passphraseConfig: config.passphraseConfig,
}, function(err, iden, firstWallet) {
if (err && !iden) {
2014-10-01 08:35:17 -03:00
console.log('Error:' + err)
controllerUtils.onErrorDigest(
$scope, (err.toString()||'').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
} else {
controllerUtils.bindProfile($scope, iden, firstWallet);
2014-10-01 08:35:17 -03:00
}
});
}
2014-09-03 01:25:08 -03:00
});