Privileges wip
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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( "<privileges-management-modal class='modal'></privileges-management-modal>")(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) {
|
||||
|
||||
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user