diff --git a/app/assets/javascripts/app/directives/views/privilegesAuthModal.js b/app/assets/javascripts/app/directives/views/privilegesAuthModal.js index 072741c34..84452687a 100644 --- a/app/assets/javascripts/app/directives/views/privilegesAuthModal.js +++ b/app/assets/javascripts/app/directives/views/privilegesAuthModal.js @@ -21,7 +21,7 @@ class PrivilegesAuthModal { } } - controller($scope, privilegesManager, $timeout) { + controller($scope, privilegesManager, passcodeManager, authManager, $timeout) { 'ngInject'; $scope.authenticationParameters = {}; @@ -37,11 +37,10 @@ class PrivilegesAuthModal { $scope.selectedSessionLength = length; } - privilegesManager.getPrivileges().then((privileges) => { + privilegesManager.netCredentialsForAction($scope.action).then((credentials) => { $timeout(() => { - $scope.privileges = privileges; - $scope.requiredCredentials = privileges.getCredentialsForAction($scope.action); - }) + $scope.requiredCredentials = credentials; + }); }); $scope.promptForCredential = function(credential) { diff --git a/app/assets/javascripts/app/services/privilegesManager.js b/app/assets/javascripts/app/services/privilegesManager.js index 8b77653af..460b23fa3 100644 --- a/app/assets/javascripts/app/services/privilegesManager.js +++ b/app/assets/javascripts/app/services/privilegesManager.js @@ -78,6 +78,27 @@ class PrivilegesManager { this.currentAuthenticationElement = el; } + async netCredentialsForAction(action) { + let credentials = (await this.getPrivileges()).getCredentialsForAction(action); + let netCredentials = []; + + for(var cred of credentials) { + if(cred == PrivilegesManager.CredentialAccountPassword) { + if(!this.authManager.offline()) { + netCredentials.push(cred); + } else { + console.log("WE ARE OFFLINE"); + } + } else if(cred == PrivilegesManager.CredentialLocalPasscode) { + if(this.passcodeManager.hasPasscode()) { + netCredentials.push(cred); + } + } + } + + return netCredentials; + } + presentPrivilegesManagementModal() { var scope = this.$rootScope.$new(true); var el = this.$compile( "")(scope); @@ -215,7 +236,7 @@ class PrivilegesManager { if(expiresAt > new Date()) { return false; } - return (await this.getPrivileges()).getCredentialsForAction(action).length > 0; + return (await this.netCredentialsForAction(action)).length > 0; } async savePrivileges() { @@ -225,7 +246,7 @@ class PrivilegesManager { } async authenticateAction(action, credentialAuthMapping) { - var requiredCredentials = (await this.getPrivileges()).getCredentialsForAction(action); + var requiredCredentials = (await this.netCredentialsForAction(action)); var successfulCredentials = [], failedCredentials = []; for(let requiredCredential of requiredCredentials) { diff --git a/app/assets/templates/directives/privileges-auth-modal.html.haml b/app/assets/templates/directives/privileges-auth-modal.html.haml index fd9074df3..972a091f6 100644 --- a/app/assets/templates/directives/privileges-auth-modal.html.haml +++ b/app/assets/templates/directives/privileges-auth-modal.html.haml @@ -8,13 +8,18 @@ %a.close-button.info{"ng-click" => "cancel()"} Cancel .content .panel-section - .panel-row{"ng-repeat" => "credential in requiredCredentials"} - %p {{promptForCredential(credential)}} - %input{"type" => "password", "ng-model" => "authenticationParameters[credential]"} - %label.danger{"ng-if" => "isCredentialInFailureState(credential)"} Invalid authentication. Please try again. + %div{"ng-repeat" => "credential in requiredCredentials"} + %p + %strong {{promptForCredential(credential)}} + %div + %input{"type" => "password", "ng-model" => "authenticationParameters[credential]"} + %div + %label.danger{"ng-if" => "isCredentialInFailureState(credential)"} Invalid authentication. Please try again. + .panel-row .panel-row .horizontal-group - %h4 Remember for + %p + %strong Remember for %a.info{"ng-repeat" => "option in sessionLengthOptions", "ng-click" => "selectSessionLength(option.value)", "ng-class" => "{'info boxed' : option.value == selectedSessionLength}"} {{option.label}}