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;
    }
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;
    }
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 ; }
Creates a non-admin user.

@param array   $data
@param integer $serviceId

@return \DreamFactory\Core\Models\User
@throws \DreamFactory\Core\Exceptions\ForbiddenException
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException
@throws \Exception
Creates a non - admin user .