Jump to content

NEED PASSWORD GENERATOR PreModuleCreate


Recommended Posts

Hello, i need a PreModuleCreate that generate a strong password that will be used in virtualizor module.

WHMCS Support provided me this hook but it gave this error https://imgur.com/AW82lbV

 

<?php

function hook_StrongPasswordGenerator($vars)
{
    $password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=+?'), 0, $length = '10');
}

add_hook('PreModuleCreate', 1, function($vars)
    {
        return array(
            'password' => $password,
        );
    }
);
Link to comment
Share on other sites

The two should be combined or you should call hook_StrongPasswordGenerator within the hook.  For example:

add_hook('PreModuleCreate', 1, function($vars)
    {
         $password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=+?'), 0, $length = '10');
         return array(
            'password' => $password,
        );
    }
);

 

Link to comment
Share on other sites

7 minutes ago, steven99 said:

The two should be combined or you should call hook_StrongPasswordGenerator within the hook.  For example:


add_hook('PreModuleCreate', 1, function($vars)
    {
         $password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=+?'), 0, $length = '10');
         return array(
            'password' => $password,
        );
    }
);

 

Hello, thank you for your reply.
I have tested this by uploading but it seems that it is not doing nothing..

https://imgur.com/G4WBzrM (order accept view)

Link to comment
Share on other sites

9 hours ago, steven99 said:

I don't think that hook saves the password to the service and thus why it does not show that.   If you updated the service, either by model / class or API, with the password (in encrypted form), it should then save and show there.  

I have tested it again with the creation of the VPS and i am getting as server password the one that i have choosen...

https://imgur.com/QWic1iz

Is there something i am missing?

Link to comment
Share on other sites

On 10/18/2021 at 4:56 AM, steven99 said:

I don't think that hook saves the password to the service and thus why it does not show that.   If you updated the service, either by model / class or API, with the password (in encrypted form), it should then save and show there.  

would you be available to help me again ...?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated