Improve 2ndFA manager module sessions search engine

This commit is contained in:
Christophe Maudoux 2018-03-22 23:04:12 +01:00
parent 57708a6b3e
commit d3368b4664
4 changed files with 14 additions and 33 deletions

View File

@ -128,6 +128,7 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
$scope.currentScope = null
$scope.currentSession = null
$scope.menu = menu
$scope.searchString = ''
# Import translations functions
$scope.translateP = $translator.translateP
@ -151,17 +152,11 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
console.log typeof button.action
$scope.showM = false
# SESSIONS MANAGEMENT
# Filter 2FA sessions
$scope.filter2FA = ->
$scope.currentSession = null
$scope.data = []
$scope.updateTree '', $scope.data, 0, 0
## SESSIONS MANAGEMENT
# Search 2FA sessions
$scope.search2FA = (clear) ->
if clear
$scope.searchString =''
$scope.searchString = ''
$scope.currentSession = null
$scope.data = []
$scope.updateTree2 '', $scope.data, 0, 0
@ -449,10 +444,8 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
$scope.waiting = false
, (resp) ->
$scope.waiting = false
# Functions to filter U2F sessions tree : download value of opened subkey
$scope.updateTree2 = (value, node, level, over, currentQuery, count) ->
$scope.waiting = true
@ -484,8 +477,8 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
else
over = 0
# Launch HTTP query
$http.get("#{scriptname}sfa/#{sessionType}?_session_uid=#{$scope.searchString}*&groupBy=_session_uid&U2FCheck=#{$scope.U2FCheck}&TOTPCheck=#{$scope.TOTPCheck}").then (response) ->
# Launch HTTP
$http.get("#{scriptname}sfa/#{sessionType}?_session_uid=#{$scope.searchString}*&groupBy=substr(_session_uid,#{$scope.searchString.length})&U2FCheck=#{$scope.U2FCheck}&TOTPCheck=#{$scope.TOTPCheck}").then (response) ->
data = response.data
if data.result
for n in data.values
@ -512,15 +505,7 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
$scope.total = data.total if value == ''
$scope.waiting = false
, (resp) ->
$scope.waiting = false
$scope.waiting = false
# Intialization function
# Simply set $scope.waiting to false during $translator and tree root

View File

@ -154,6 +154,7 @@
$scope.currentScope = null;
$scope.currentSession = null;
$scope.menu = menu;
$scope.searchString = '';
$scope.translateP = $translator.translateP;
$scope.translate = $translator.translate;
$scope.translateTitle = function(node) {
@ -180,11 +181,6 @@
}
return $scope.showM = false;
};
$scope.filter2FA = function() {
$scope.currentSession = null;
$scope.data = [];
return $scope.updateTree('', $scope.data, 0, 0);
};
$scope.search2FA = function(clear) {
if (clear) {
$scope.searchString = '';
@ -508,7 +504,7 @@
} else {
over = 0;
}
return $http.get(scriptname + "sfa/" + sessionType + "?_session_uid=" + $scope.searchString + "*&groupBy=_session_uid&U2FCheck=" + $scope.U2FCheck + "&TOTPCheck=" + $scope.TOTPCheck).then(function(response) {
return $http.get(scriptname + "sfa/" + sessionType + "?_session_uid=" + $scope.searchString + "*&groupBy=substr(_session_uid," + $scope.searchString.length + ")&U2FCheck=" + $scope.U2FCheck + "&TOTPCheck=" + $scope.TOTPCheck).then(function(response) {
var data, i, len, n, ref;
data = response.data;
if (data.result) {

File diff suppressed because one or more lines are too long

View File

@ -15,9 +15,9 @@
<li><a id="a-persistent" role="row"><i class="glyphicon glyphicon-exclamation-sign"></i> {{translate('2faSessions')}}</a></li>
<form name="filterForm">
<div class="form-check ">&nbsp;&nbsp;&nbsp;
<input type="checkbox" ng-model="U2FCheck" class="form-check-input" ng-true-value="'2'" ng-false-value="'1'" ng-change="filter2FA()"/>
<input type="checkbox" ng-model="U2FCheck" class="form-check-input" ng-true-value="'2'" ng-false-value="'1'" ng-change="search2FA()"/>
<label class="form-check-label" for="U2FCheck">U2F</label>&nbsp;&nbsp;
<input type="checkbox" ng-model="TOTPCheck" class="form-check-input" ng-true-value="'2'" ng-false-value="'1'" ng-change="filter2FA()"/>
<input type="checkbox" ng-model="TOTPCheck" class="form-check-input" ng-true-value="'2'" ng-false-value="'1'" ng-change="search2FA()"/>
<label class="form-check-label" for="TOTPCheck">TOTP</label>
</div>
</form>
@ -25,7 +25,7 @@
<div class="col-lg-6 col-md-6 col-sm-7 " >
<form class="navbar-form" role="search">
<div class="input-group add-on">
<input class="form-control" placeholder="{{translate('search')}}" type="text" ng-model="searchString" ng-init="*" ng-keyup="search2FA()"/>
<input class="form-control" placeholder="{{translate('search')}}" type="text" ng-model="searchString" ng-init="" ng-keyup="search2FA()"/>
<div class="input-group-btn">
<button class="btn btn-default" ng-click="search2FA(1)"><i class="glyphicon glyphicon-search"></i></button>
</div>