public function create(array $data, $serviceId = null)
    {
        /** @var \DreamFactory\Core\User\Services\User $userService */
        $userService = ServiceManager::getService('user');
        if (!$userService->allowOpenRegistration) {
            throw new ForbiddenException('Open Registration is not enabled.');
        }

        /** @type User $user */
        $user = User::create($data);

        if (!empty($userService->openRegEmailServiceId)) {
            $this->sendConfirmation($user, $userService->openRegEmailServiceId, $userService->openRegEmailTemplateId);
        } else if (!empty($data['password'])) {
            $user->password = $data['password'];
            $user->save();
        }

        if (!empty($userService->openRegRoleId)) {
            User::applyDefaultUserAppRole($user, $userService->openRegRoleId);
        }
        if (!empty($serviceId)) {
            User::applyAppRoleMapByService($user, $serviceId);
        }

        return $user;
    }