Add setting realm.accessCodeLifespanUserAction in admin console

This commit is contained in:
Stian Thorgersen 2013-10-25 12:39:25 +01:00
parent 26b28be04c
commit 45b5f5afd5
5 changed files with 31 additions and 4 deletions

View file

@ -200,9 +200,10 @@ module.controller('RealmRequiredCredentialsCtrl', function($scope, Realm, realm,
module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, $location, Dialog, Notifications) {
console.log('RealmTokenDetailCtrl');
$scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, tokenLifespan : realm.tokenLifespan, accessCodeLifespan : realm.accessCodeLifespan };
$scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, tokenLifespan : realm.tokenLifespan, accessCodeLifespan : realm.accessCodeLifespan , accessCodeLifespanUserAction : realm.accessCodeLifespanUserAction };
$scope.realm.tokenLifespanUnit = 'Seconds';
$scope.realm.accessCodeLifespanUnit = 'Seconds';
$scope.realm.accessCodeLifespanUserActionUnit = 'Seconds';
var oldCopy = angular.copy($scope.realm);
$scope.changed = false;
@ -218,6 +219,7 @@ module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http,
var realmCopy = angular.copy($scope.realm);
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') {
@ -232,6 +234,13 @@ module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http,
} 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;
}
$scope.changed = false;
Realm.update(realmCopy, function () {
$location.url("/realms/" + realm.id + "/token-settings");

View file

@ -48,6 +48,20 @@
</div>
</div>
</div>
<div class="form-group input-select">
<label for="accessCodeLifespanUserAction">Access code user action lifespan</label>
<div class="input-group">
<input type="text" data-ng-model="realm.accessCodeLifespanUserAction" id="accessCodeLifespanUserAction" name="accessCodeLifespanUserAction" class="tiny">
<div class="select-rcue">
<select name="accessCodeLifespanUserActionUnit" data-ng-model="realm.accessCodeLifespanUserActionUnit">
<option data-ng-selected="!realm.accessCodeLifespanUserActionUnit">Seconds</option>
<option>Minutes</option>
<option>Hours</option>
<option>Days</option>
</select>
</div>
</div>
</div>
</fieldset>
<div class="form-actions">
<button type="submit" data-ng-click="save()" class="primary" data-ng-show="changed">Save

View file

@ -104,7 +104,7 @@ public class RealmRepresentation {
this.enabled = enabled;
}
public Boolean isAccountManagement() {
public Boolean getAccountManagement() {
return accountManagement;
}

View file

@ -91,7 +91,7 @@ public class RealmManager {
realm.updateDefaultRoles(rep.getDefaultRoles());
}
if (rep.isAccountManagement()) {
if (rep.getAccountManagement() != null && rep.getAccountManagement()) {
enableAccountManagement(realm);
} else {
disableAccountManagement(realm);
@ -253,7 +253,7 @@ public class RealmManager {
}
}
if (rep.isAccountManagement() != null && rep.isAccountManagement()) {
if (rep.getAccountManagement() != null && rep.getAccountManagement()) {
enableAccountManagement(newRealm);
}

View file

@ -221,6 +221,10 @@ public class KeycloakServer {
}
new ApplianceBootstrap().bootstrap(session);
// No need to require admin to change password as this server is for dev/test
manager.getRealm(Constants.ADMIN_REALM).getUser("admin").removeRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD);
session.getTransaction().commit();
} finally {
session.close();