mirror of https://github.com/BTCPrivate/copay.git
create working
This commit is contained in:
parent
a70d04af77
commit
d3726d658c
|
@ -50,7 +50,16 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.selectStorage = function (storage) {
|
|
||||||
|
$scope.setStep = function(step) {
|
||||||
|
$scope.error = null;
|
||||||
|
$scope.createStep = step;
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$digest();
|
||||||
|
}, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.selectStorage = function(storage) {
|
||||||
$scope.useLocalstorage = storage == 'local';
|
$scope.useLocalstorage = storage == 'local';
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
|
@ -58,14 +67,11 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.goToEmail = function() {
|
$scope.goToEmail = function() {
|
||||||
console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO
|
|
||||||
$scope.createStep = 'email';
|
$scope.createStep = 'email';
|
||||||
$scope.useEmail = !$scope.useLocalstorage;
|
$scope.useEmail = !$scope.useLocalstorage;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setEmailOrUsername = function(form) {
|
$scope.setEmailOrUsername = function(form) {
|
||||||
console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO
|
|
||||||
|
|
||||||
$scope.userOrEmail = $scope.useLocalstorage ? form.username.$modelValue : form.email.$modelValue;
|
$scope.userOrEmail = $scope.useLocalstorage ? form.username.$modelValue : form.email.$modelValue;
|
||||||
preconditions.checkState($scope.userOrEmail);
|
preconditions.checkState($scope.userOrEmail);
|
||||||
|
|
||||||
|
@ -91,29 +97,23 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope._doCreateProfile = function(emailOrUsername, password) {
|
$scope._doCreateProfile = function(emailOrUsername, password, cb) {
|
||||||
preconditions.checkArgument(_.isString(emailOrUsername));
|
preconditions.checkArgument(_.isString(emailOrUsername));
|
||||||
preconditions.checkArgument(_.isString(password));
|
preconditions.checkArgument(_.isString(password));
|
||||||
|
|
||||||
|
$rootScope.hideNavigation = false;
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
identityService.create(emailOrUsername, password, function(err) {
|
identityService.create(emailOrUsername, password, function(err) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
$scope.error = null;
|
||||||
if (err) {
|
if (err) {
|
||||||
var msg = err.toString();
|
var msg = err.toString();
|
||||||
if (msg.indexOf('EEXIST') >= 0 || msg.indexOf('BADC') >= 0) {
|
if (msg.indexOf('EEXIST') >= 0 || msg.indexOf('BADC') >= 0) {
|
||||||
msg = 'This profile already exists'
|
msg = 'This profile already exists'
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
|
||||||
form.password.$setViewValue('');
|
|
||||||
form.password.$render();
|
|
||||||
form.repeatpassword.$setViewValue('');
|
|
||||||
form.repeatpassword.$render();
|
|
||||||
form.$setPristine();
|
|
||||||
$scope.error = msg;
|
|
||||||
}, 1);
|
|
||||||
$scope.error = msg;
|
$scope.error = msg;
|
||||||
} else {
|
} else {
|
||||||
$scope.error = null;
|
|
||||||
// mobile
|
// mobile
|
||||||
if ($scope.isMobile) {
|
if ($scope.isMobile) {
|
||||||
_credentials = {
|
_credentials = {
|
||||||
|
@ -125,38 +125,46 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$scope.createDefaultWallet();
|
$scope.createDefaultWallet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cb();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.createProfile = function(form) {
|
$scope.saveSettings = function(cb) {
|
||||||
$rootScope.hideNavigation = false;
|
|
||||||
if (form && form.$invalid) {
|
|
||||||
$scope.error = 'Please enter the required fields';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$scope.loading = true;
|
|
||||||
|
|
||||||
var plugins = config.plugins;
|
var plugins = config.plugins;
|
||||||
|
|
||||||
plugins.EncryptedLocalStorage = false;
|
plugins.EncryptedLocalStorage = false;
|
||||||
plugins.EncryptedInsightStorage = false;
|
plugins.EncryptedInsightStorage = false;
|
||||||
|
|
||||||
var pluginName = $scope.useLocalstorage ? 'EncryptedLocalStorage' : 'EncryptedInsightStorage';
|
var pluginName = $scope.useLocalstorage ? 'EncryptedLocalStorage' : 'EncryptedInsightStorage';
|
||||||
|
|
||||||
plugins[pluginName] = true;
|
plugins[pluginName] = true;
|
||||||
console.log('[createProfile.js.102:plugins:]', plugins); //TODO
|
|
||||||
|
|
||||||
configService.set({
|
configService.set({
|
||||||
plugins: plugins
|
plugins: plugins
|
||||||
}, function() {
|
}, cb);
|
||||||
$scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue);
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.createProfile = function(form) {
|
||||||
|
if (form && form.$invalid) {
|
||||||
|
$scope.error = 'Please enter the required fields';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.saveSettings(function(err) {
|
||||||
|
$scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) {
|
||||||
|
$timeout(function() {
|
||||||
|
form.password.$setViewValue('');
|
||||||
|
form.password.$render();
|
||||||
|
form.repeatpassword.$setViewValue('');
|
||||||
|
form.repeatpassword.$render();
|
||||||
|
form.$setPristine();
|
||||||
|
}, 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
>
|
>
|
||||||
<div class="box-setup-footer">
|
<div class="box-setup-footer">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<a class="text-gray" ng-click="createStep='storage'">
|
<a class="text-gray" ng-click="setStep('storage')">
|
||||||
<i class="icon-arrow-left4"></i>
|
<i class="icon-arrow-left4"></i>
|
||||||
<span translate>Back</span>
|
<span translate>Back</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
|
|
||||||
<div class="box-setup-footer">
|
<div class="box-setup-footer">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<a class="text-gray" ng-click="createStep='email'">
|
<a class="text-gray" ng-click="setStep('email')">
|
||||||
<i class="icon-arrow-left4"></i>
|
<i class="icon-arrow-left4"></i>
|
||||||
<span translate>Back</span>
|
<span translate>Back</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue