To add the public function setCurrentPath($currentPath)

Created on 28 September 2017, about 7 years ago
Updated 16 March 2023, almost 2 years ago

Hello.

I have a question.

I just want to know, any easy way to make like

$restrictIp = new RestrictIp(); 
$restrictIp->setPath('/user/login');
$is_allowed_path = $restrictIp->testForBlock();

I use this module to protect /user/login and /user/register pages and it works well for me.
But user still can login using a custom login form.

So I want to implement in my custom module like

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MYMODULE_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['#validate'][] = '_MYMODULE_login_form_validate';

}

/**
 * Validation form for the login form.
 */
function _MYMODULE_login_form_validate($form, FormStateInterface &$form_state) {
  // TODO:  Get RestrictIpService() and check userIsBlocked or not.
}

I see RestrictIpService.php but unclear how can I pass a lot of parameters to the constructor.

Thank you in advance.

✨ Feature request
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine ruslan piskarov Kyiv, Ukraine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024