Wallet/js/controllers/createProfile.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-09-30 21:16:46 -03:00
'use strict';
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, notification, pluginManager, identityService) {
2014-11-29 18:35:48 -03:00
identityService.goWalletHome();
2014-09-30 21:16:46 -03:00
$scope.createProfile = function(form) {
2014-10-09 18:53:31 -03:00
if (form && form.$invalid) {
$scope.error('Error', 'Please enter the required fields');
2014-10-09 18:53:31 -03:00
return;
}
2014-11-30 03:58:38 -03:00
$rootScope.starting = true;
2014-11-30 00:31:17 -03:00
identityService.create(
form.email.$modelValue, form.password.$modelValue, function(err) {
2014-11-30 03:58:38 -03:00
$rootScope.starting = false;
if (err) {
var msg = err.toString();
if (msg.indexOf('EEXIST')>=0 || msg.indexOf('BADC')>=0 ) {
msg = 'This profile already exists'
}
$timeout(function() {
form.email.$setViewValue('');
form.email.$render();
form.password.$setViewValue('');
form.password.$render();
form.repeatpassword.$setViewValue('');
form.repeatpassword.$render();
form.$setPristine();
$scope.error = msg;
},1);
2014-11-30 03:58:38 -03:00
}
2014-11-30 00:31:17 -03:00
});
2014-09-30 21:16:46 -03:00
}
});