givanz / Vvveb

Powerful and easy to use cms to build websites, blogs or ecommerce stores.
https://www.vvveb.com
GNU Affero General Public License v3.0
241 stars 49 forks source link

Multi tenancy support #62

Open bigaboxau opened 6 months ago

bigaboxau commented 6 months ago

Could you please consider adding multi-tenancy support to enhance the script's functionality? It would be a game-changer for our project.

alternatively if you can suggest how to achieve that in the current version.

givanz commented 6 months ago

In the last update https://github.com/givanz/Vvveb/commit/727c2241b0687bcdf2e663f8c801e56d10c034f3 admin user has site restriction ability, you will need to redownload latest.zip and update files.

https://demo.vvveb.com/admin/?module=admin/user&admin_id=3

With the current setup you can restrict admin user to access only specific sites.

There are some limitations with media library that is shared for all sites. I will make some changes to allow support for more flexible media library storage in the upcoming updates with the posibility to make it site specific with a plugin or allow s3 storage.

Most settings like ecommerce settings, taxes, statuses etc are not site specific for true separation a separate install for each user is needed.

You can use automated installation using cli as a base for separated multi tenant setup.

cd new-site
unzip ../path-to-zip/latest.zip 

# add engine=sqlite to use sqlite if desired
php cli.php install module=index host=127.0.0.1 user=root password= database=vvveb admin[email]=admin@vvveb.com admin[password]=123456

# add new admin user
php cli.php admin module=admin/user action=save admin[email]=user1@example.com admin[username]=user2 admin[first_name]="John" admin[last_name]="Doe" admin[display_name]="User 1" admin[role_id]=2 admin[status]=1

# add new site
php cli.php admin module=settings/site action action=save site[name]="my-site" site[host]=subdomain.domain.com site[theme]=landing settings[title]="My website" settings[admin-email]=user@domain.com settings[description]="My site"

You can call any admin module from cli, you can view the module name for a page in the url.