Privileges wip
This commit is contained in:
@@ -21,7 +21,7 @@ class PrivilegesAuthModal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controller($scope, privilegesManager, $timeout) {
|
controller($scope, privilegesManager, passcodeManager, authManager, $timeout) {
|
||||||
'ngInject';
|
'ngInject';
|
||||||
|
|
||||||
$scope.authenticationParameters = {};
|
$scope.authenticationParameters = {};
|
||||||
@@ -37,11 +37,10 @@ class PrivilegesAuthModal {
|
|||||||
$scope.selectedSessionLength = length;
|
$scope.selectedSessionLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
privilegesManager.getPrivileges().then((privileges) => {
|
privilegesManager.netCredentialsForAction($scope.action).then((credentials) => {
|
||||||
$timeout(() => {
|
$timeout(() => {
|
||||||
$scope.privileges = privileges;
|
$scope.requiredCredentials = credentials;
|
||||||
$scope.requiredCredentials = privileges.getCredentialsForAction($scope.action);
|
});
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.promptForCredential = function(credential) {
|
$scope.promptForCredential = function(credential) {
|
||||||
|
|||||||
@@ -78,6 +78,27 @@ class PrivilegesManager {
|
|||||||
this.currentAuthenticationElement = el;
|
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() {
|
presentPrivilegesManagementModal() {
|
||||||
var scope = this.$rootScope.$new(true);
|
var scope = this.$rootScope.$new(true);
|
||||||
var el = this.$compile( "<privileges-management-modal class='modal'></privileges-management-modal>")(scope);
|
var el = this.$compile( "<privileges-management-modal class='modal'></privileges-management-modal>")(scope);
|
||||||
@@ -215,7 +236,7 @@ class PrivilegesManager {
|
|||||||
if(expiresAt > new Date()) {
|
if(expiresAt > new Date()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (await this.getPrivileges()).getCredentialsForAction(action).length > 0;
|
return (await this.netCredentialsForAction(action)).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async savePrivileges() {
|
async savePrivileges() {
|
||||||
@@ -225,7 +246,7 @@ class PrivilegesManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async authenticateAction(action, credentialAuthMapping) {
|
async authenticateAction(action, credentialAuthMapping) {
|
||||||
var requiredCredentials = (await this.getPrivileges()).getCredentialsForAction(action);
|
var requiredCredentials = (await this.netCredentialsForAction(action));
|
||||||
var successfulCredentials = [], failedCredentials = [];
|
var successfulCredentials = [], failedCredentials = [];
|
||||||
|
|
||||||
for(let requiredCredential of requiredCredentials) {
|
for(let requiredCredential of requiredCredentials) {
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
%a.close-button.info{"ng-click" => "cancel()"} Cancel
|
%a.close-button.info{"ng-click" => "cancel()"} Cancel
|
||||||
.content
|
.content
|
||||||
.panel-section
|
.panel-section
|
||||||
.panel-row{"ng-repeat" => "credential in requiredCredentials"}
|
%div{"ng-repeat" => "credential in requiredCredentials"}
|
||||||
%p {{promptForCredential(credential)}}
|
%p
|
||||||
%input{"type" => "password", "ng-model" => "authenticationParameters[credential]"}
|
%strong {{promptForCredential(credential)}}
|
||||||
%label.danger{"ng-if" => "isCredentialInFailureState(credential)"} Invalid authentication. Please try again.
|
%div
|
||||||
|
%input{"type" => "password", "ng-model" => "authenticationParameters[credential]"}
|
||||||
|
%div
|
||||||
|
%label.danger{"ng-if" => "isCredentialInFailureState(credential)"} Invalid authentication. Please try again.
|
||||||
|
.panel-row
|
||||||
.panel-row
|
.panel-row
|
||||||
.horizontal-group
|
.horizontal-group
|
||||||
%h4 Remember for
|
%p
|
||||||
|
%strong Remember for
|
||||||
%a.info{"ng-repeat" => "option in sessionLengthOptions", "ng-click" => "selectSessionLength(option.value)",
|
%a.info{"ng-repeat" => "option in sessionLengthOptions", "ng-click" => "selectSessionLength(option.value)",
|
||||||
"ng-class" => "{'info boxed' : option.value == selectedSessionLength}"}
|
"ng-class" => "{'info boxed' : option.value == selectedSessionLength}"}
|
||||||
{{option.label}}
|
{{option.label}}
|
||||||
|
|||||||
Reference in New Issue
Block a user