Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add weight option #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/install/tfa.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ setup_plugins: { }
send_plugins: { }
login_plugins: { }
validate_plugins: { }
validate_weights: { }
validate_weights: { }
weight: 9
3 changes: 3 additions & 0 deletions config/schema/tfa.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ tfa.settings:
validate_weights:
type: sequence
label: 'Validation plugins weights'
weight:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please annotate this as tab_weight, weight is too ambiguous here

type: integer
label: 'Weight of the tab'
9 changes: 9 additions & 0 deletions src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $config->get('enabled'),
'#description' => t('Enable TFA for account authentication.'),
);

// Option to set tfa tab in userprofile
$form['weight'] = array(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code formatting issues, please run PHPCS on this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename all uses of "weight" to "tab_weight"

'#type' => 'weight',
'#title' => $this->t('Weight of the tfa tab'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, 'Weight of TFA tab' instead of 'Weight of tfa tab'

'#default_value' => $config->get('weight'),
'#delta' => 30,
);

//@TODO Figure out why we allow multiple validation plugins?
if (count($validate_plugins)) {
Expand Down Expand Up @@ -285,6 +293,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

$this->config('tfa.settings')
->set('enabled', $form_state->getValue('tfa_enabled'))
->set('weight', $form_state->getValue('weight'))
->set('setup_plugins', array_filter($form_state->getValue('tfa_setup')))
->set('send_plugins', array_filter($form_state->getValue('tfa_send')))
->set('login_plugins', array_filter($form_state->getValue('tfa_login')))
Expand Down