Jump to content

Sync users between installations


Recommended Posts

Hi,

i'm looking for a way to automatically sync users from a main installation to (multiple) other installations which all live on the the same server (pw native multi-site).

Is there an easy way to do this?

Or is the "easy way" to get all the users (with a specific role) via multi-instance (https://processwire.com/blog/posts/multi-instance-pw3/#using-multi-instance-in-pw3) and import/update them regularly (cron job) and disable profile editing for the subsites?

Thanks!

Link to comment
Share on other sites

It's not exactly what you're asking for, but it could be helpful or a first approach to solve your problem: In a ProcessWire multi-instance environment, I needed to get the logged-in user of the central PW instance in all the others and found the following solution. Requires to use different session cookie names in each installation and SessionHandlerDB installed.

$config->sessionName = wire0;
$config->sessionName = wire1;

https://github.com/processwire/processwire-issues/issues/1294#issuecomment-759351593

 

  • Like 2
Link to comment
Share on other sites

@kixe

Nice! But I don't think this would work for me.

Does this work with backend access and editing? My users need access to every backend to edit content. But I don't want them to manage multiple profiles with (worst case) different passwords. 

Link to comment
Share on other sites

If a user is succesfully loggedin in another instance you can force login in the current (only if the user name matches) – no password required. Checkout the code I posted:

21 hours ago, kixe said:

and add this:

$xy->users->setCurrentUser($_user); // search for this
wire('session')->forceLogin($_user->name); // add this

I would assign profile-edit permission only in the main instance. All this needs a bit coding experience. Be careful and don't create security holes!

  • Like 1
Link to comment
Share on other sites

I don't know how well you know the PW API but it's easy to hook in Pages::delete() and Pages::save()
In your sattelite instances you just need a name for each user, nothing else. Manage the users in your main instance only and update users via PW API in the others.

What is your special usecase? Why do you have multiple PW Installs for the same users?

Link to comment
Share on other sites

Thanks!

 

Quote

What is your special usecase? Why do you have multiple PW Installs for the same users?

It's my way for a multi-site installation, which I can't/won't use because it's also multilanguage and an existing installation with lot's of pages. So I thought, this would be the easier way.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...