2014-09-30 21:16:46 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2014-12-02 18:53:14 -03:00
|
|
|
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) {
|
2014-11-01 21:34:03 -03:00
|
|
|
$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'
|
|
|
|
|
}
|
2014-12-02 18:53:14 -03:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
});
|