Bug 37711: Domains CRUD update

This patch adapts the `Identity provider domains` CRUD page to handle
the new configuration options.

To test:
1. Have an IdP with some domains set. Make sure there's at least one
   domain with auto-register enabled and one with it disabled.
2. Apply this patches
3. Run:
   $ ktd --shell
  k$ updatedatabase
=> SUCCESS: Updates successfully
4. Run:
  k$ yarn build
5. Refresh the IdP domains page
=> SUCCESS: The domains table shows both OPAC and staff auto-register
   options.
=> SUCCESS: The staff auto-register is disabled for both domains
=> SUCCESS: The OPAC auto-register matches what was set for each domain
regarding auto-register (remember that before this patchset,
auto-register only works for the OPAC).
6. Play with editing/adding/removing domain configurations
=> SUCCESS: Things work as expected, values are persisted on the DB
correctly.
7. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2024-08-22 15:50:16 -03:00 committed by Lucas Gass
parent 3eb91ce952
commit 6290b9ac7b
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 70 additions and 44 deletions

View File

@ -63,9 +63,10 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
my $protocol = $input->param('protocol');
# Domain configuration params
my $allow_opac = $input->param('allow_opac') // 0;
my $allow_staff = $input->param('allow_staff') // 0;
my $auto_register = $input->param('auto_register') // 0;
my $allow_opac = $input->param('allow_opac') // 0;
my $allow_staff = $input->param('allow_staff') // 0;
my $auto_register_opac = $input->param('auto_register_opac') // 0;
my $auto_register_staff = $input->param('auto_register_staff') // 0;
my $default_category_id = $input->param('default_category_id');
my $default_library_id = $input->param('default_library_id');
my $domain = $input->param('domain');
@ -91,7 +92,8 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
identity_provider_id => $provider->identity_provider_id,
allow_opac => $allow_opac,
allow_staff => $allow_staff,
auto_register => $auto_register,
auto_register_opac => $auto_register_opac,
auto_register_staff => $auto_register_staff,
default_category_id => $default_category_id,
default_library_id => $default_library_id,
domain => $domain,
@ -120,7 +122,8 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
my $allow_opac = $input->param('allow_opac');
my $allow_staff = $input->param('allow_staff');
my $identity_provider_id = $input->param('identity_provider_id');
my $auto_register = $input->param('auto_register');
my $auto_register_opac = $input->param('auto_register_opac');
my $auto_register_staff = $input->param('auto_register_staff');
my $default_category_id = $input->param('default_category_id') || undef;
my $default_library_id = $input->param('default_library_id') || undef;
my $domain = $input->param('domain');
@ -133,7 +136,8 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
allow_opac => $allow_opac,
allow_staff => $allow_staff,
identity_provider_id => $identity_provider_id,
auto_register => $auto_register,
auto_register_opac => $auto_register_opac,
auto_register_staff => $auto_register_staff,
default_category_id => $default_category_id,
default_library_id => $default_library_id,
domain => $domain,
@ -245,7 +249,8 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
my $identity_provider_id = $input->param('identity_provider_id');
my $domain = $input->param('domain');
my $auto_register = $input->param('auto_register');
my $auto_register_opac = $input->param('auto_register_opac') // 0;
my $auto_register_staff = $input->param('auto_register_staff') // 0;
my $update_on_auth = $input->param('update_on_auth');
my $default_library_id = $input->param('default_library_id') || undef;
my $default_category_id = $input->param('default_category_id') || undef;
@ -258,7 +263,8 @@ if ( !$domain_ops && $op eq 'cud-add' ) {
{
identity_provider_id => $identity_provider_id,
domain => $domain,
auto_register => $auto_register,
auto_register_opac => $auto_register_opac,
auto_register_staff => $auto_register_staff,
update_on_auth => $update_on_auth,
default_library_id => $default_library_id,
default_category_id => $default_category_id,

View File

@ -116,12 +116,20 @@
<span>user data on login</span>
</li>
<li>
<label for="auto_register">Auto register: </label>
<select name="auto_register" id="auto_register">
<label for="auto_register_opac">Auto register (OPAC): </label>
<select name="auto_register_opac" id="auto_register_opac">
<option value="1">Allow</option>
<option value="0" selected="selected">Don't allow</option>
</select>
<span>users to auto register on login</span>
<span>users to auto register on login (OPAC)</span>
</li>
<li>
<label for="auto_register_staff">Auto register (Staff interface): </label>
<select name="auto_register_staff" id="auto_register_staff">
<option value="1">Allow</option>
<option value="0" selected="selected">Don't allow</option>
</select>
<span>users to auto register on login (Staff interface)</span>
</li>
<li>
<label for="default_library_id">Default library: </label>
@ -205,9 +213,9 @@
<span>user data on login</span>
</li>
<li>
<label for="auto_register">Auto register: </label>
<select name="auto_register" id="auto_register">
[% IF identity_provider_domain.auto_register == "1" %]
<label for="auto_register_opac">Auto register (OPAC): </label>
<select name="auto_register_opac" id="auto_register_opac">
[% IF identity_provider_domain.auto_register_opac == "1" %]
<option value="1" selected="selected">Allow</option>
<option value="0">Don't allow</option>
[% ELSE %]
@ -215,7 +223,20 @@
<option value="0" selected="selected">Don't allow</option>
[% END %]
</select>
<span>users to auto register on login</span>
<span>users to auto register on OPAC login</span>
</li>
<li>
<label for="auto_register_staff">Auto register (Staff): </label>
<select name="auto_register_staff" id="auto_register_staff">
[% IF identity_provider_domain.auto_register_staff == "1" %]
<option value="1" selected="selected">Allow</option>
<option value="0">Don't allow</option>
[% ELSE %]
<option value="1">Allow</option>
<option value="0" selected="selected">Don't allow</option>
[% END %]
</select>
<span>users to auto register on staff interface login</span>
</li>
<li>
<label for="default_library_id">Default library: </label>
@ -289,38 +310,18 @@
<tr>
<th>Domain</th>
<th>Update on login</th>
<th>Auto register</th>
<th>Auto register (OPAC)</th>
<th>Auto register (Staff)</th>
<th>Default library</th>
<th>Default category</th>
<th>Allow OPAC</th>
<th>Allow staff</th>
<th data-class-name="actions no-export">Actions</th>
<th data-class-name="actions noExport">Actions</th>
</tr>
</thead>
</table>
</div>
[% END %]
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="delete_confirm_modal_label">Confirm deletion of identity provider domain</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="delete_confirm_dialog"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-danger" id="delete_confirm_modal_button" role="button" data-bs-toggle="modal">Delete</a>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- #delete_confirm_modal -->
[% END %]
[% MACRO jsinclude BLOCK %]
@ -390,7 +391,18 @@
},
{
"data": function( row, type, val, meta ) {
if (row.auto_register) {
if (row.auto_register_opac) {
return _("Yes");
} else {
return _("No");
}
},
"searchable": true,
"orderable": true
},
{
"data": function( row, type, val, meta ) {
if (row.auto_register_staff) {
return _("Yes");
} else {
return _("No");

View File

@ -211,12 +211,20 @@
<div class="hint">Allow staff access to users from this domain to login with this identity provider.</div>
</li>
<li>
<label for="auto_register">Auto register: </label>
<select name="auto_register" id="auto_register">
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
<label for="auto_register_opac">Auto register (OPAC): </label>
<select name="auto_register_opac" id="auto_register_opac">
<option value="1">Allow</option>
<option value="0" selected="selected">Don't allow</option>
</select>
<div class="hint">Allow users to auto register on login.</div>
<span>users to auto register on login (OPAC)</span>
</li>
<li>
<label for="auto_register_staff">Auto register (Staff interface): </label>
<select name="auto_register_staff" id="auto_register_staff">
<option value="1">Allow</option>
<option value="0" selected="selected">Don't allow</option>
</select>
<span>users to auto register on login (Staff interface)</span>
</li>
<li>
<label for="update_on_auth">Update on login: </label>