copay/js/services/identityService.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

'use strict';
angular.module('copayApp.services')
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
var root = {};
2014-10-24 07:58:22 -07:00
root.create = function (scope, form) {
copay.Identity.create({
email: form.email.$modelValue,
password: form.password.$modelValue,
pluginManager: pluginManager,
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
passphraseConfig: config.passphraseConfig,
}, function(err, iden) {
var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet);
scope.loading = false;
});
};
2014-10-24 07:58:22 -07:00
root.open = function (scope, form) {
copay.Identity.open({
email: form.email.$modelValue,
password: form.password.$modelValue,
2014-10-24 07:58:22 -07:00
pluginManager: pluginManager,
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
passphraseConfig: config.passphraseConfig,
}, function(err, iden) {
2014-10-24 07:58:22 -07:00
if (err && !iden) {
console.log('Error:' + err)
controllerUtils.onErrorDigest(
scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
} else {
var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet);
2014-10-24 07:58:22 -07:00
}
scope.loading = false;
});
}
return root;
});