Add redirect URL to a config form
This commit is contained in:
parent
3a516626fa
commit
56a1728b1a
3 changed files with 17 additions and 0 deletions
7
auth.php
7
auth.php
|
@ -56,6 +56,7 @@ class auth_plugin_userkey extends auth_plugin_base {
|
|||
'mappingfield' => self::DEFAULT_MAPPING_FIELD,
|
||||
'keylifetime' => 60,
|
||||
'iprestriction' => 0,
|
||||
'redirecturl' => '',
|
||||
// TODO: use this field when implementing user creation. 'createuser' => 0.
|
||||
);
|
||||
|
||||
|
@ -172,6 +173,8 @@ class auth_plugin_userkey extends auth_plugin_base {
|
|||
* @param array $userfields
|
||||
*/
|
||||
public function config_form($config, $err, $userfields) {
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
$config = (object) array_merge($this->defaults, (array) $config );
|
||||
include("settings.html");
|
||||
}
|
||||
|
@ -189,6 +192,10 @@ class auth_plugin_userkey extends auth_plugin_base {
|
|||
if ((int)$form->keylifetime == 0) {
|
||||
$err['keylifetime'] = 'User key life time should be a number.';
|
||||
}
|
||||
|
||||
if (!empty($form->redirecturl) && filter_var($form->redirecturl, FILTER_VALIDATE_URL) === false) {
|
||||
$err['redirecturl'] = get_string('incorrectredirecturl', 'auth_userkey');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,5 +32,8 @@ $string['keylifetime'] = 'User key life time';
|
|||
$string['keylifetime_desc'] = 'Life time in seconds of the each user login key.';
|
||||
$string['createuser'] = 'Crete user?';
|
||||
$string['createuser_desc'] = 'If enabled, a new user will be created if fail to find one in LMS.';
|
||||
$string['redirecturl'] = 'Logout redirect URL';
|
||||
$string['redirecturl_desc'] = 'Optionally you can redirect users to this URL after they logged out from LMS.';
|
||||
$string['incorrectredirecturl'] = 'You should provide valid URL';
|
||||
$string['userkey:generatekey'] = 'Generate login user key';
|
||||
$string['pluginisdisabled'] = 'The userkey authentication plugin is disabled.';
|
|
@ -49,6 +49,13 @@ $fields = get_auth_plugin('userkey')->get_allowed_mapping_fields();
|
|||
<?php if (isset($err[$field])) { echo $OUTPUT->notification($err[$field], 'notifyfailure'); } ?>
|
||||
<?php print_string($field.'_desc', 'auth_userkey')?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<?php $field = 'redirecturl' ?>
|
||||
<td align="right"><label for="<?php echo $field ?>"><?php print_string($field, 'auth_userkey') ?></label></td>
|
||||
<td><input type="text" size="60" name="<?php echo $field ?>" value="<?php print $config->$field ?>" placeholder=""><br>
|
||||
<?php if (isset($err[$field])) { echo $OUTPUT->notification($err[$field], 'notifyfailure'); } ?>
|
||||
<?php print_string($field.'_desc', 'auth_userkey') ?></td>
|
||||
</tr>
|
||||
<!--UNCOMMENT FOLLOWING WHEN IMPLEMENT USER CREATION.-->
|
||||
<!--<tr valign="top">-->
|
||||
<!--<?php $field = 'createuser' ?>-->
|
||||
|
|
Loading…
Reference in a new issue