Wallet/src/js/controllers/password.js

44 lines
1 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
angular.module('copayApp.controllers').controller('passwordController',
2015-09-29 15:48:55 -03:00
function($rootScope, $scope, $timeout, profileService, notification, go, gettext) {
2015-03-06 12:00:10 -03:00
var self = this;
var pass1;
self.isVerification = false;
2015-09-29 15:48:55 -03:00
document.getElementById("passwordInput").focus();
self.close = function(cb) {
2015-03-06 12:00:10 -03:00
return cb('No password given');
};
2015-09-29 15:48:55 -03:00
self.set = function(isSetup, cb) {
2015-03-06 12:00:10 -03:00
self.error = false;
if (isSetup && !self.isVerification) {
2015-09-29 15:48:55 -03:00
document.getElementById("passwordInput").focus();
2015-03-06 12:00:10 -03:00
self.isVerification = true;
2015-09-29 15:48:55 -03:00
pass1 = self.password;
2015-03-06 12:00:10 -03:00
self.password = null;
2015-09-29 15:48:55 -03:00
$timeout(function() {
2015-03-06 12:00:10 -03:00
$rootScope.$apply();
})
return;
}
if (isSetup) {
if (pass1 != self.password) {
self.error = gettext('Passwords do not match');
2015-03-06 12:00:10 -03:00
self.isVerification = false;
self.password = null;
2015-09-29 15:48:55 -03:00
pass1 = null;
2015-03-06 12:00:10 -03:00
return;
}
}
return cb(null, self.password);
};
2015-09-29 15:48:55 -03:00
});