Checking for equivalent domains from settings
This commit is contained in:
parent
bb56f9ee47
commit
54119e1e94
|
@ -7,9 +7,9 @@ var cryptoService = new CryptoService(constantsService);
|
|||
var tokenService = new TokenService();
|
||||
var apiService = new ApiService(tokenService);
|
||||
var userService = new UserService(tokenService, apiService, cryptoService);
|
||||
var loginService = new LoginService(cryptoService, userService, apiService);
|
||||
var folderService = new FolderService(cryptoService, userService, apiService);
|
||||
var settingsService = new SettingsService(userService);
|
||||
var loginService = new LoginService(cryptoService, userService, apiService, settingsService);
|
||||
var folderService = new FolderService(cryptoService, userService, apiService);
|
||||
var syncService = new SyncService(loginService, folderService, userService, apiService, settingsService);
|
||||
var autofillService = new AutofillService();
|
||||
var passwordGenerationService = new PasswordGenerationService();
|
||||
|
|
|
@ -41,17 +41,9 @@ angular
|
|||
canAutofill = true;
|
||||
});
|
||||
|
||||
var filteredLogins = [];
|
||||
var loginPromise = $q.when(loginService.getAllDecrypted());
|
||||
loginPromise.then(function (logins) {
|
||||
for (var i = 0; i < logins.length; i++) {
|
||||
if (logins[i].domain && logins[i].domain === domain) {
|
||||
filteredLogins.push(logins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
$q.when(loginService.getAllDecryptedForDomain(domain)).then(function (logins) {
|
||||
$scope.loaded = true;
|
||||
$scope.logins = filteredLogins;
|
||||
$scope.logins = logins;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
function LoginService(cryptoService, userService, apiService) {
|
||||
function LoginService(cryptoService, userService, apiService, settingsService) {
|
||||
this.cryptoService = cryptoService;
|
||||
this.userService = userService;
|
||||
this.apiService = apiService;
|
||||
this.settingsService = settingsService;
|
||||
this.decryptedLoginCache = null;
|
||||
|
||||
initLoginService();
|
||||
|
@ -133,10 +134,29 @@ function initLoginService() {
|
|||
LoginService.prototype.getAllDecryptedForDomain = function (domain) {
|
||||
var self = this;
|
||||
|
||||
return self.getAllDecrypted().then(function (logins) {
|
||||
var eqDomainsPromise = self.settingsService.getEquivalentDomains().then(function (eqDomains) {
|
||||
var matchingDomains = [];
|
||||
for (var i = 0; i < eqDomains.length; i++) {
|
||||
for (var j = 0; j < eqDomains[i].length; j++) {
|
||||
if (eqDomains[i][j] === domain) {
|
||||
matchingDomains = matchingDomains.concat(eqDomains[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchingDomains;
|
||||
});
|
||||
|
||||
var loginsPromise = self.getAllDecrypted().then(function (logins) {
|
||||
return logins;
|
||||
});
|
||||
|
||||
return Q.all([eqDomainsPromise, loginsPromise]).then(function (result) {
|
||||
var matchingDomains = result[0];
|
||||
var logins = result[1];
|
||||
var loginsToReturn = [];
|
||||
for (var i = 0; i < logins.length; i++) {
|
||||
if (logins[i].domain === domain) {
|
||||
if (logins[i].domain && matchingDomains.indexOf(logins[i].domain) >= 0) {
|
||||
loginsToReturn.push(logins[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,13 @@ function initSettingsService() {
|
|||
};
|
||||
|
||||
SettingsService.prototype.getEquivalentDomains = function (callback) {
|
||||
getSettingsKey(this, 'equivalentDomains', callback);
|
||||
var deferred = Q.defer();
|
||||
|
||||
getSettingsKey(this, 'equivalentDomains', function (domains) {
|
||||
deferred.resolve(domains);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
function getSettingsKey(self, key, callback) {
|
||||
|
|
|
@ -188,7 +188,9 @@ function initSyncService() {
|
|||
}
|
||||
if (response && response.globalEquivalentDomains) {
|
||||
for (var i = 0; i < response.globalEquivalentDomains.length; i++) {
|
||||
eqDomains = eqDomains.concat(response.globalEquivalentDomains[i].domains);
|
||||
if (response.globalEquivalentDomains[i].domains.length) {
|
||||
eqDomains.push(response.globalEquivalentDomains[i].domains);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue