[英]Drupal - Validate form before submit / Encrypt password before send it
I would like to modify (encrypt) the login password in Drupal, before it sends it decrypted to server. 在将解密后的登录密码发送到服务器之前,我想修改(加密)Drupal中的登录密码。 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! 谢谢!
this module will help you Encryption 该模块将帮助您加密
Create your custom module and use hook_form_alter to add a new custom validation and submission callbacks: 创建您的自定义模块,并使用hook_form_alter添加新的自定义验证和提交回调:
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. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.