Skip to content

Commit

Permalink
Merge pull request #8 from MESH-Research/develop
Browse files Browse the repository at this point in the history
Add logic to populate username in form with default from environment
  • Loading branch information
rekmla authored Jun 23, 2021
2 parents 4d0da60 + a3212c1 commit 017725c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions Config/Schema/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<field name="ldap_bind_password" type="C" size="64" />
<field name="ldap_basedn" type="C" size="128" />
<field name="hc_idp_scope" type="C" size="64" />
<field name="username_env_variable" type="C" size="256" />
<field name="debug" type="L" />
<field name="created" type="T" />
<field name="modified" type="T" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ protected function execute_plugin_checkEligibility($id, $onFinish) {

// GET, fall through to display view
( $debug ? $this->log($logPrefix . "received GET so displaying form to collect username") : null);

$this->set('vv_efwid', $efwid);

if(!empty($config['HumanitiesCommonsIdpEnroller']['username_env_variable'])) {
$this->set('vv_suggested_username', getenv($config['HumanitiesCommonsIdpEnroller']['username_env_variable']));
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
'pl.humanitiescommonsidpenroller.config.ldap_basedn.desc' => 'Base DN to provision accounts under',
'pl.humanitiescommonsidpenroller.config.hc_idp_scope' => 'Humanities Commons IdP Scope',
'pl.humanitiescommonsidpenroller.config.hc_idp_scope.desc' => 'Scope asserted by the Humanities Commons IdP (hcommons.org)',
'pl.humanitiescommonsidpenroller.config.username_env_variable' => 'Username Environment Variable Default',
'pl.humanitiescommonsidpenroller.config.username_env_variable.desc' => 'Environment variable used to set username default in form',
'pl.humanitiescommonsidpenroller.config.debug' => 'Debug',
'pl.humanitiescommonsidpenroller.config.debug.desc' => 'Toggle for debug mode',
'pl.humanitiescommonsidpenroller.config.menu' => 'HC IdP Enroller Configuration',
Expand Down
7 changes: 6 additions & 1 deletion Model/HumanitiesCommonsIdpEnroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ class HumanitiesCommonsIdpEnroller extends AppModel {
'rule' => 'notBlank',
'required' => true,
'allowEmpty' => false
)
),
'username_env_variable' => array(
'rule' => array('validateInput'),
'required' => false,
'allowEmpty' => true
),
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
$args['type'] = 'text';
$args['label'] = false;
$args['required'] = 'required';
if( $current_enrollment_flow_cou == 'MSU' ) {
$args['value'] = getenv('netid');
}
if(!empty($vv_suggested_username)) {
$args['value'] = $vv_suggested_username;
}
print $this->Form->input('username', $args);
?>
<span id="username-error" class="field-error"></span>
Expand Down
9 changes: 9 additions & 0 deletions View/HumanitiesCommonsIdpEnrollers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
<?php print ($e ? $this->Form->input('hc_idp_scope', array('size' => 50)) : Sanitize::html($humanities_commons_idp_enrollers[0]['HumanitiesCommonsIdpEnroller']['hc_idp_scope'])); ?>
</td>
</tr>
<tr class="line<?php print ($l % 2); $l++; ?>">
<td>
<strong class="fieldTitle"><?php print _txt('pl.humanitiescommonsidpenroller.config.username_env_variable'); ?></strong><br />
<font class="desc"><?php print _txt('pl.humanitiescommonsidpenroller.config.username_env_variable.desc'); ?></font>
</td>
<td>
<?php print ($e ? $this->Form->input('username_env_variable', array('size' => 50)) : Sanitize::html($humanities_commons_idp_enrollers[0]['HumanitiesCommonsIdpEnroller']['username_env_variable'])); ?>
</td>
</tr>
<tr class="line<?php print ($l % 2); $l++; ?>">
<td>
<strong class="fieldTitle"><?php print _txt('pl.humanitiescommonsidpenroller.config.debug'); ?></strong><font class="required">*</font><br />
Expand Down

0 comments on commit 017725c

Please sign in to comment.