Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
e3cee387e8
12 changed files with 97 additions and 46 deletions
|
@ -431,8 +431,8 @@ module.directive('onoffswitch', function() {
|
|||
offText: '@offText'
|
||||
},
|
||||
compile: function(element, attrs) {
|
||||
if (!attrs.onText) { attrs.onText = "ON"; }
|
||||
if (!attrs.offText) { attrs.offText = "OFF"; }
|
||||
if (!attrs.onText) { attrs.onText = "YES"; }
|
||||
if (!attrs.offText) { attrs.offText = "NO"; }
|
||||
|
||||
var html = "<div class=\"onoffswitch\">" +
|
||||
"<input type=\"checkbox\" data-ng-model=\"ngModel\" class=\"onoffswitch-checkbox\" name=\"" + attrs.name + "\" id=\"" + attrs.id + "\">" +
|
||||
|
|
|
@ -484,16 +484,29 @@ module.controller('RealmSocialCtrl', function($scope, realm, Realm, $location, N
|
|||
|
||||
});
|
||||
|
||||
module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, $location, Dialog, Notifications) {
|
||||
module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, $location, Dialog, Notifications, TimeUnit) {
|
||||
console.log('RealmTokenDetailCtrl');
|
||||
|
||||
$scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, registrationAllowed : realm.registrationAllowed,
|
||||
tokenLifespan : realm.tokenLifespan, accessCodeLifespan : realm.accessCodeLifespan,
|
||||
accessCodeLifespanUserAction : realm.accessCodeLifespanUserAction };
|
||||
$scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, registrationAllowed : realm.registrationAllowed };
|
||||
|
||||
$scope.realm.tokenLifespanUnit = TimeUnit.autoUnit(realm.tokenLifespan);
|
||||
$scope.realm.tokenLifespan = TimeUnit.toUnit(realm.tokenLifespan, $scope.realm.tokenLifespanUnit);
|
||||
$scope.$watch('realm.tokenLifespanUnit', function(to, from) {
|
||||
$scope.realm.tokenLifespan = TimeUnit.convert($scope.realm.tokenLifespan, from, to);
|
||||
});
|
||||
|
||||
$scope.realm.accessCodeLifespanUnit = TimeUnit.autoUnit(realm.accessCodeLifespan);
|
||||
$scope.realm.accessCodeLifespan = TimeUnit.toUnit(realm.accessCodeLifespan, $scope.realm.accessCodeLifespanUnit);
|
||||
$scope.$watch('realm.accessCodeLifespanUnit', function(to, from) {
|
||||
$scope.realm.accessCodeLifespan = TimeUnit.convert($scope.realm.accessCodeLifespan, from, to);
|
||||
});
|
||||
|
||||
$scope.realm.accessCodeLifespanUserActionUnit = TimeUnit.autoUnit(realm.accessCodeLifespanUserAction);
|
||||
$scope.realm.accessCodeLifespanUserAction = TimeUnit.toUnit(realm.accessCodeLifespanUserAction, $scope.realm.accessCodeLifespanUserActionUnit);
|
||||
$scope.$watch('realm.accessCodeLifespanUserActionUnit', function(to, from) {
|
||||
$scope.realm.accessCodeLifespanUserAction = TimeUnit.convert($scope.realm.accessCodeLifespanUserAction, from, to);
|
||||
});
|
||||
|
||||
$scope.realm.tokenLifespanUnit = 'Seconds';
|
||||
$scope.realm.accessCodeLifespanUnit = 'Seconds';
|
||||
$scope.realm.accessCodeLifespanUserActionUnit = 'Seconds';
|
||||
|
||||
var oldCopy = angular.copy($scope.realm);
|
||||
$scope.changed = false;
|
||||
|
@ -509,27 +522,11 @@ module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http,
|
|||
delete realmCopy["tokenLifespanUnit"];
|
||||
delete realmCopy["accessCodeLifespanUnit"];
|
||||
delete realmCopy["accessCodeLifespanUserActionUnit"];
|
||||
if ($scope.realm.tokenLifespanUnit == 'Minutes') {
|
||||
realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60;
|
||||
} else if ($scope.realm.tokenLifespanUnit == 'Hours') {
|
||||
realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60 * 60;
|
||||
} else if ($scope.realm.tokenLifespanUnit == 'Days') {
|
||||
realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60 * 60 * 24;
|
||||
}
|
||||
if ($scope.realm.accessCodeLifespanUnit == 'Minutes') {
|
||||
realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60;
|
||||
} else if ($scope.realm.accessCodeLifespanUnit == 'Hours') {
|
||||
realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60 * 60;
|
||||
} else if ($scope.realm.accessCodeLifespanUnit == 'Days') {
|
||||
realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60 * 60 * 24;
|
||||
}
|
||||
if ($scope.realm.accessCodeLifespanUserActionUnit == 'Minutes') {
|
||||
realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60;
|
||||
} else if ($scope.realm.accessCodeLifespanUserActionUnit == 'Hours') {
|
||||
realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60 * 60;
|
||||
} else if ($scope.realm.accessCodeLifespanUserActionUnit == 'Days') {
|
||||
realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60 * 60 * 24;
|
||||
}
|
||||
|
||||
realmCopy.tokenLifespan = TimeUnit.toSeconds($scope.realm.tokenLifespan, $scope.realm.tokenLifespanUnit)
|
||||
realmCopy.accessCodeLifespan = TimeUnit.toSeconds($scope.realm.accessCodeLifespan, $scope.realm.accessCodeLifespanUnit)
|
||||
realmCopy.accessCodeLifespanUserAction = TimeUnit.toSeconds($scope.realm.accessCodeLifespanUserAction, $scope.realm.accessCodeLifespanUserActionUnit)
|
||||
|
||||
$scope.changed = false;
|
||||
Realm.update(realmCopy, function () {
|
||||
$location.url("/realms/" + realm.id + "/token-settings");
|
||||
|
|
|
@ -120,9 +120,15 @@ module.controller('UserListCtrl', function($scope, realm, User) {
|
|||
$scope.realm = realm;
|
||||
$scope.searchQuery = function() {
|
||||
$scope.searchLoaded = false;
|
||||
if ($scope.search) {
|
||||
$scope.currentSearch = $scope.search;
|
||||
$scope.users = User.query({ realm: realm.id, search : $scope.search }, function() {
|
||||
$scope.searchLoaded = true;
|
||||
});
|
||||
} else {
|
||||
$scope.currentSearch = null;
|
||||
$scope.users = null;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -226,9 +226,6 @@ module.factory('ApplicationOrigins', function($resource) {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
module.factory('Current', function(Realm, $route) {
|
||||
var current = {};
|
||||
|
||||
|
@ -254,3 +251,51 @@ module.factory('Current', function(Realm, $route) {
|
|||
|
||||
return current;
|
||||
});
|
||||
|
||||
module.factory('TimeUnit', function() {
|
||||
var t = {};
|
||||
|
||||
t.autoUnit = function(time) {
|
||||
var unit = 'Seconds';
|
||||
if (time % 60 == 0) {
|
||||
unit = 'Minutes';
|
||||
time = time / 60;
|
||||
}
|
||||
if (time % 60 == 0) {
|
||||
unit = 'Hours';
|
||||
time = time / 60;
|
||||
}
|
||||
if (time % 24 == 0) {
|
||||
unit = 'Days'
|
||||
time = time / 24;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
t.toSeconds = function(time, unit) {
|
||||
switch (unit) {
|
||||
case 'Seconds': return time;
|
||||
case 'Minutes': return time * 60;
|
||||
case 'Hours': return time * 360;
|
||||
case 'Days': return time * 86400;
|
||||
default: throw 'invalid unit ' + unit;
|
||||
}
|
||||
}
|
||||
|
||||
t.toUnit = function(time, unit) {
|
||||
switch (unit) {
|
||||
case 'Seconds': return time;
|
||||
case 'Minutes': return Math.ceil(time / 60);
|
||||
case 'Hours': return Math.ceil(time / 360);
|
||||
case 'Days': return Math.ceil(time / 86400);
|
||||
default: throw 'invalid unit ' + unit;
|
||||
}
|
||||
}
|
||||
|
||||
t.convert = function(time, from, to) {
|
||||
var seconds = t.toSeconds(time, from);
|
||||
return t.toUnit(seconds, to);
|
||||
}
|
||||
|
||||
return t;
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<div class="input-group">
|
||||
<input type="text" data-ng-model="realm.tokenLifespan" id="tokenLifespan" name="tokenLifespan" class="tiny">
|
||||
<div class="select-rcue">
|
||||
<select name="tokenLifespanUnit" data-ng-model="realm.tokenLifespanUnit">
|
||||
<select name="tokenLifespanUnit" data-ng-model="realm.tokenLifespanUnit" >
|
||||
<option data-ng-selected="!realm.tokenLifespanUnit">Seconds</option>
|
||||
<option>Minutes</option>
|
||||
<option>Hours</option>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr data-ng-show="users.length > 0">
|
||||
<tr data-ng-show="searchLoaded && users.length > 0">
|
||||
<th>Username</th>
|
||||
<th>Last Name</th>
|
||||
<th>First Name</th>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<div class="feedback warning inline" data-ng-show="searchLoaded && users.length == 0">
|
||||
<p><strong>Your search returned no results.</strong><br>Try modifying the query and try again.</p>
|
||||
</div>
|
||||
<div class="feedback info inline" data-ng-show="!search">
|
||||
<div class="feedback info inline" data-ng-show="!currentSearch">
|
||||
<br/>
|
||||
<p><strong>Search for users.</strong><br>Please enter a search to display users.</p>
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
|
||||
<connection-url>jdbc:h2:${jboss.server.data.dir}/keycloak;DB_CLOSE_DELAY=-1</connection-url>
|
||||
<connection-url>jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE</connection-url>
|
||||
<driver>h2</driver>
|
||||
<security>
|
||||
<user-name>sa</user-name>
|
||||
|
|
2
dist/src/main/xslt/standalone.xsl
vendored
2
dist/src/main/xslt/standalone.xsl
vendored
|
@ -14,7 +14,7 @@
|
|||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
|
||||
<connection-url>jdbc:h2:${jboss.server.data.dir}/keycloak;DB_CLOSE_DELAY=-1</connection-url>
|
||||
<connection-url>jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE</connection-url>
|
||||
<driver>h2</driver>
|
||||
<security>
|
||||
<user-name>sa</user-name>
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-entitymanager</artifactId>
|
||||
<version>${hibernate.entitymanager.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
|
|
|
@ -666,7 +666,8 @@ public class RealmAdapter implements RealmModel {
|
|||
|
||||
@Override
|
||||
public List<UserModel> searchForUser(String search) {
|
||||
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where lower(u.loginName) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search", UserEntity.class);
|
||||
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where u.realm = :realm and lower(u.loginName) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search", UserEntity.class);
|
||||
query.setParameter("realm", realm);
|
||||
query.setParameter("search", "%" + search.toLowerCase() + "%");
|
||||
List<UserEntity> results = query.getResultList();
|
||||
List<UserModel> users = new ArrayList<UserModel>();
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -15,7 +15,7 @@
|
|||
<mongo.driver.version>2.11.2</mongo.driver.version>
|
||||
<jboss.logging.version>3.1.1.GA</jboss.logging.version>
|
||||
<hibernate.javax.persistence.version>1.0.1.Final</hibernate.javax.persistence.version>
|
||||
<hibernate.entitymanager.version>3.6.6.Final</hibernate.entitymanager.version>
|
||||
<hibernate.entitymanager.version>4.0.1.Final</hibernate.entitymanager.version>
|
||||
<h2.version>1.3.161</h2.version>
|
||||
<dom4j.version>1.6.1</dom4j.version>
|
||||
<mysql.version>5.1.25</mysql.version>
|
||||
|
|
|
@ -303,6 +303,7 @@ public class AdapterTest extends AbstractKeycloakTest {
|
|||
}
|
||||
|
||||
RealmManager adapter = getRealmManager();
|
||||
adapter.createRealm("other").addUser("bburke");
|
||||
|
||||
{
|
||||
List<UserModel> userModels = adapter.searchUsers("total junk query", realmModel);
|
||||
|
|
Loading…
Reference in a new issue