Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
When you try to create a user with Ask password option, Identity Server will create a random password for that user using the extension class org.wso2.carbon.user.mgt.common.DefaultPasswordGenerator, until the user configures a new password. So when you enable a Password Policy [1] it might give an error if the generated random password violates the policy that you have defined in your configurations.
To overcome that issue you can write a custom random password generator which does not violate your password policy. I have attached sample code (wso2-sample-custom-password-generator.zip) of a custom password generator for your reference. And do the following steps to use your custom password generator for ask password option.
Build the custom password generator source and get the com.wso2.password.policy-1.0.0.jar file.
Copy the jar file into /repository/components/lib directory.
Start the server.
Then you need to configure your custom password generator class form the management console in order to use it instead of DefaultPasswordGenerator. Please do the following steps.
Click Resident under Identity Providers found in the Main tab of the IS management console.
Expand the Account Management Policies tab.
Expand the User Onboarding tab and define your custom password generator class in Temporary password generation extension class section. (ex: com.wso2.password.policy.CustomPasswordGenerator)
Then you should be able to create a new user with ask password option without any issue.
Add the above sample for Ask password documentation [2].
it looks like this was already added to the codebase here. However, I wasn't able to find any mention of custom password generators in the documentation
When you try to create a user with Ask password option, Identity Server will create a random password for that user using the extension class org.wso2.carbon.user.mgt.common.DefaultPasswordGenerator, until the user configures a new password. So when you enable a Password Policy [1] it might give an error if the generated random password violates the policy that you have defined in your configurations.
To overcome that issue you can write a custom random password generator which does not violate your password policy. I have attached sample code (wso2-sample-custom-password-generator.zip) of a custom password generator for your reference. And do the following steps to use your custom password generator for ask password option.
Then you should be able to create a new user with ask password option without any issue.
Add the above sample for Ask password documentation [2].
[1] https://docs.wso2.com/display/IS541/Password+Patterns [2] https://docs.wso2.com/display/IS541/Creating+Users+using+the+Ask+Password+Option