Craft CMS V3 Create New User Having difficulties creating a new user in a custom controller, here's my implementation:

use craft\records\User;

$user = new User;
$user-&gt;firstName = $userData['firstName'];
$user-&gt;lastName = $userData['lastName'];
$user-&gt;username = $userData['loginName'];
$user-&gt;email = $userData['loginName'];
$user-&gt;password = $userData['password'];

$response = $user-&gt;insert();


Response:

SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value
The SQL being executed was: INSERT INTO `craft_users` (`firstName`, `lastName`, `username`, `email`, `password`, `dateCreated`, `uid`, `dateUpdated`) VALUES ('Tristan', 'Gemus', 'registertest@gmail.com', 'registertest@gmail.com', 'password', '2019-03-28 15:53:10', '85468ad6-63cc-499d-baf4-32aaaf55bfb2', '2019-03-28 15:53:10')


The response returns false. Thoughts?
Take a look at Craft's own UsersController->actionSaveUser().

You're probably looking for something closer to this:

$user = new craft\elements\User();

$user-&gt;firstName = $firstName;
$user-&gt;lastName = $lastName;
$user-&gt;username = $userName;
$user-&gt;email = $email;
$user-&gt;password = $password;

if ($user-&gt;validate(null, false)) {
    Craft::$app-&gt;getElements()-&gt;saveElement($user, false);
}