Torsten Baldes Posted June 3, 2021 Share Posted June 3, 2021 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 More sharing options...
kixe Posted June 3, 2021 Share Posted June 3, 2021 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 2 Link to comment Share on other sites More sharing options...
Torsten Baldes Posted June 4, 2021 Author Share Posted June 4, 2021 @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 More sharing options...
kixe Posted June 4, 2021 Share Posted June 4, 2021 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: https://github.com/processwire/processwire-issues/issues/1294#issuecomment-759351593 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! 1 Link to comment Share on other sites More sharing options...
Torsten Baldes Posted June 4, 2021 Author Share Posted June 4, 2021 Thanks! Yes, that could be my way to login. But the user also has to have an account in the other instance to login. That's the problem where my sync question comes from. Link to comment Share on other sites More sharing options...
kixe Posted June 4, 2021 Share Posted June 4, 2021 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 More sharing options...
Torsten Baldes Posted June 4, 2021 Author Share Posted June 4, 2021 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 More sharing options...
Torsten Baldes Posted June 10, 2021 Author Share Posted June 10, 2021 @kixe Do you have any special settings for the sessions? $xy->session->hasCookie(true) is always false, where $xy->session->hasCookie() is true. (I'm logged in to xy.) Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now