0

I would like to modify (encrypt) the login password in Drupal, before it sends it decrypted to server. I didn't find any module to do that (validation before submission), and I couldn't find a way of validate the fields before they are sent to server.

Is there a way to solve it?

Thank you!

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
user1695700
  • 71
  • 2
  • 12

2 Answers2

2

this module will help you Encryption

Mina Atia
  • 780
  • 1
  • 4
  • 13
-1

Create your custom module and use hook_form_alter to add a new custom validation and submission callbacks:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id == "user_profile_form") {
        $form['#validate'][] = 'your_new_validation_callback';
        $form['#submit'][] = 'your_new_submission_callback';
    }
}

function your_new_validation_callback($form, &$form_state)
{
    // add your validation logic
}

function your_new_submission_callback($form, &$form_state)
{
    // add your submission logic
}

Hope this helps.

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • Hi! But I would need the validation "before" it sends from client-side to server-side. This way it won't work, will it? Thanks! – user1695700 Apr 10 '13 at 14:53
  • That's the whole purpose of validation. It is called **before** submission. And if something goes wrong you can use [`form_set_error`](http://api.drupal.org/api/drupal/includes!form.inc/function/form_set_error/6) to file an error against a form element. In which case your submission function is not reached. – Max Apr 10 '13 at 16:00
  • As far as http traffic goes, the op is right: this way does not alter the data that gets sent from the browser to the server. The validation only kicks in when the data reaches the server un the form of an HTTP POST request. – kekkis Apr 10 '13 at 18:29