<![CDATA[ Login: Separate Logins, different Users - My Forums]]> https://forums.modx.com/thread/?thread=98328 <![CDATA[Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users?page=2#dis-post-531641
Is there a way to define the following scenario:


  • 2 Login forms
  • 2 users
  • 2 Landing pages
  • 2 Logout pages

The goal is to achieve that User1 can login on Login 1 and User2 on Login2. But that login is denied when User1 tries to login on Login2 (and vice versa).

Is there a way to it?

I know there is the possibility to redirect users according to their usergroups or/and usernames (Thread http://forums.modx.com/thread/?thread=72130&page=1). But this is a feasible solution.

Thanks for your help.]]>
achterbahn Sep 17, 2015, 05:31 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users?page=2#dis-post-531641
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531895 BobRay Sep 21, 2015, 03:00 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531895 <![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531842
Why to different logins?
A comany has a website with to products (p1 and p2). Each of the products have a menu-tree and a "login/download" section (and therefore a separate login form).

Now I can use Login with two different logins (users u1 and u2) to decide if a customer can login to the respective login-section or not.

But: if u1 is logging in on p1, then the login form on p2 also has the status "logged in". With the Extra from redirectusergroups and/or the snippet from Bob it is possible to direct the user to the "right" landing page and avoid that he sees the download page not meant for him.
But it is not possible to split it completely, i.e. u1 logs in for p1, and the login form for p2 still shows the login form.

Hope I could clarify me idea.

Quote from: markh at Sep 20, 2015, 07:44 AM
If you're trying to show something different depending on the user group, Personalize might be what you're looking for: http://modx.com/extras/package/personalize

I'm still confused why you need two different login forms though. Why can't they both use the same login form? Or is one person supposed to login twice?
]]>
achterbahn Sep 20, 2015, 08:20 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531842
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531821 http://modx.com/extras/package/personalize

I'm still confused why you need two different login forms though. Why can't they both use the same login form? Or is one person supposed to login twice?]]>
markh Sep 20, 2015, 02:44 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531821
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531780 BobRay Sep 19, 2015, 11:59 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531780 <![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531745
You're absolutely right.
I was just wondering what it would need to acheive the functionality to completely separate two logins on one page. And you answered it: Login would need a submission key.
]]>
achterbahn Sep 18, 2015, 04:58 PM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531745
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531740
The problem is that Login has no submission key that would allow it to be used twice on the same page. Even if you have separate &loginResourceId properties in your two Login tags, all users will be sent to the first one because that login tag will always execute first.

If you're not satisfied with redirectUserGroups, you could easily have just one Login form and use a Login postHook to send the users to their appropriate page. Adding my snippets would make sure that neither user could access the other page directly. The redirectUserGroups extra won't prevent them from going directly to the other user's page if they can figure out the url.

If you're determined to have two forms, I think you could use JavaScript fired by onSubmit() in the two buttons that would run a processor to log the user in and forward them to the right page, but you'd still need my code, or the permissions system, to make sure they couldn't access the unauthorized page directly.]]>
BobRay Sep 18, 2015, 04:01 PM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531740
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531712
This I a nice solution, but unfortunately not for my case, because after login I do not show menu entries for the logged in users, but only redirect it to a corresponding page. So the use of Bruno's script is the workaround I can use.

What I had in mind was a Login-Extra that had a setting for user groups (or users) to check against. I.e. it would show the login form or the "logged in" depending on that check. So it would be possible to run to completely separated login structures on one page.
Could the Login Extra be expanded by that functionality? Just out of interest.

Best regards
fabian

Quote from: BobRay at Sep 17, 2015, 08:09 PM
You could put a snippet at the top of the landing pages with code like this:

$id = $modx->user->get('id');
if ($id != 12) {
   return 'Sorry, you're not allowed to see this page';
}


You'd change 12 to the ID of the user who was not authorized on each page.

You could also just redirect unauthorized users back to the login page:

$id = $modx->user->get('id');
if ($id != 12) {
   $url = $modx->makeUrl(22, "", "", "full"); // change 22 to the ID of the login page
   $modx->sendRedirect($url);
   return '';
}




]]>
achterbahn Sep 18, 2015, 04:53 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531712
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531684
$id = $modx->user->get('id');
if ($id != 12) {
   return 'Sorry, you're not allowed to see this page';
}


You'd change 12 to the ID of the user who was not authorized on each page.

You could also just redirect unauthorized users back to the login page:

$id = $modx->user->get('id');
if ($id != 12) {
   $url = $modx->makeUrl(22, "", "", "full"); // change 22 to the ID of the login page
   $modx->sendRedirect($url);
   return '';
}




]]>
BobRay Sep 17, 2015, 03:09 PM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531684
<![CDATA[Re: Login: Separate Logins, different Users]]> https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531660
it is not exactly what I was looking for, but it will help as a workaround.

If someone else could be interested in how I made it:
Modal Login form -> Jquery Ajax call --> Resource with Snippet Call --> Snippet: executes Login (return success or error) --> Ajax redirects to resource --> Resources dispatches with Extra redirectusergroups

Btw Bruno: i didn't found your Extra in the package management...]]>
achterbahn Sep 17, 2015, 10:15 AM https://forums.modx.com/thread/98328/login-separate-logins-different-users#dis-post-531660