I'm wanting to create a user without specifying the password and have FusionAuth send the Setup Password email. I'm using the PHP client library, and while I can create a user the email is not been sent. However manually dispatching a Reset Password email is delivered successfully.
I've configured the SMTP settings to use my Mailgun account.
Here's what I'm sending via the client;
$this->authClient->createUser(null, [
'user' => [
'active' => true,
'sendSetPasswordEmail' => true,
'birthDate' => '01/01/1990',
'email' => 'a.valid@email.co.uk',
'firstName' => 'John',
'fullName' => 'John Doe',
'lastName' => 'Doe',
'middleName' => '',
'mobilePhone' => +447777777777,
'password' => 'ForSomeReasonThisNEEDStoBeSet',
'data' => [
'identifier' => $someIdentifier
],
'memberships' => [
['groupId' => $myGroupId]
],
'preferredLanguages' => ['en'],
'timezone' => 'Europe/London',
'twoFactorEnabled' => false,
'usernameStatus' => 'ACTIVE',
'username' => $username,
'verified' => true
]
]);
Even when I'm passing the sendSetPasswordEmail
the password
field is still required, however the docs suggest this shouldn't be the case;
This field is optional only if sendSetPasswordEmail is set to true. By default sendSetPasswordEmail is false, and then this field will be required.
How can I get the Password Setup email to be send when creating a user? Thanks in advance
The sendSetPasswordEmail
is a top level value in the JSON request. You need to move it up as a sibling to the user
object.
Example:
$this->authClient->createUser(null, [
'sendSetPasswordEmail' => true,
'user' => [
'active' => true,
'birthDate' => '01/01/1990',
'email' => 'a.valid@email.co.uk',
'firstName' => 'John',
'fullName' => 'John Doe',
'lastName' => 'Doe',
'middleName' => '',
'mobilePhone' => +447777777777,
'password' => 'ForSomeReasonThisNEEDStoBeSet',
'data' => [
'identifier' => $someIdentifier
],
'memberships' => [
['groupId' => $myGroupId]
],
'preferredLanguages' => ['en'],
'timezone' => 'Europe/London',
'twoFactorEnabled' => false,
'usernameStatus' => 'ACTIVE',
'username' => $username,
'verified' => true
]
]);
Reference Create User API