fix create profile

This commit is contained in:
Matias Alejo Garcia 2014-11-30 03:58:38 -03:00
commit 1e013b1bb6
7 changed files with 37 additions and 34 deletions

View file

@ -1,21 +1,24 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, pluginManager, identityService) {
identityService.goWalletHome();
$scope.loading = false;
$scope.createProfile = function(form) {
if (form && form.$invalid) {
$scope.error('Error', 'Please enter the required fields');
return;
}
$rootScope.starting = true;
identityService.create(
form.email.$modelValue, form.password.$modelValue, function(err) {
if (err) $scope.error('Error', err.toString());
$rootScope.$digest();
$rootScope.starting = false;
if (err) {
var msg = err.toString();
if (msg.indexOf('EEXIST')>=0 || msg.indexOf('BADC')>=0 ) {
msg = 'This profile already exists'
}
$scope.error = msg;
}
});
}
});