You are here

public function SecureLoginManager::secureForm in Secure Login 8

Rewrites the form action to use the secure base URL.

1 call to SecureLoginManager::secureForm()
SecureLoginManager::userLoginBlockPreRender in src/SecureLoginManager.php
Pre-render callback to re-secure the user login block.

File

src/SecureLoginManager.php, line 61

Class

SecureLoginManager
Defines the secure login service.

Namespace

Drupal\securelogin

Code

public function secureForm(&$form) {

  // Rebuild this form on based on the actual URL.
  $form['#cache']['contexts'][] = 'securelogin';

  // Flag form as secure for theming purposes.
  $form['#https'] = TRUE;
  if ($this->request
    ->isSecure()) {
    return;
  }

  // Redirect to secure page, if enabled.
  if ($this->config
    ->get('secure_forms')) {

    // Disable caching, as this form must be rebuilt to set the redirect.
    $form['#cache']['max-age'] = 0;
    $this
      ->secureRedirect();
  }
  $form['#action'] = $this
    ->secureUrl($form['#action']);
}