Deep Linking /w Login

Permalink
I'm trying to setup a password protected section of my site using permissions. Setup is no trouble but linking to a page in the protected section when not logged in is not redirecting back to the page after successfully logging in. Instead, I'm being redirected to the home page.

I noticed on concrete5.org that the url includes additional url path segments (/forward/...) after the login page and when login is complete, you end up back on the page you were trying to access.

Any thoughts on deep linking to a protected page?

Thanks in advance!

dwhillier
 
Responsive replied on at Permalink Reply
Responsive
dwhillier replied on at Permalink Reply
dwhillier
Not exactly, but thanks!

Let me see if I can provide an example.

The following URL requires a registered user account to access it:

http://www.mysite.com/clients/acmeco/...

When a guest user tries to access the page, they are redirected to the login screen so they can login in order to access the page. Once logging in, they should be redirected back to the above page, but instead are getting redirected to the home page.

Just trying to go through the code, looks like it should still work ...
Responsive replied on at Permalink Reply
Responsive
"When a guest user tries to access the page, they are redirected to the login screen so they can login in order to access the page."
this is the standard Login screen ?

"Once logging in, they should be redirected back to the above page, but instead are getting redirected to the home page."
So why not use the Custom page option or is this for a specific user group only ?
dwhillier replied on at Permalink Reply
dwhillier
Yes, the built in login screen, C5 automatically redirects an anonymous user to the login page if the page they are trying to access requires them to be logged in.

The 'Custom page' functionality defines a single page for everyone. I'm not needing to redirecting everyone to a single page once they log in. I'm really not even concerned about redirecting individual groups to specific pages at login (though that might help short term).

I'm talking about accessing any of a number of password protected pages directly via bookmark or email url. This used to work fine in C5.6 ... trying to track down what happened in C5.7 or at least my install of C5.7 (lastest version)

If you have a whole series of client documentation within a section of your site that must be accessed with a user account, you would want to be able to link someone to a specific page within that protected section of your site, have C5 ask them to login using the default C5 login page and then automatically send them back to the originally linked page so they could read it. Right now, I'm getting sent to the home page instead.
jeromeb replied on at Permalink Reply
Did you find a solution to your problem?
jeromeb replied on at Permalink Reply
Hi,

I have the same concern and I would like to take my users to the link we have posted on a site, blog, or email after logging in instead of being directed only to these login destinations - homepage, custom page, or member profile. Any help would be very much appreciated.
dwhillier replied on at Permalink Reply
dwhillier
Been digging into the core of 5.6.3.2 and comparing to 5.7.3.1. Looks like the forwarding functionality is found in the view method of page_forbidden controller.

5.6.3.2:
class Concrete5_Controller_PageForbidden extends LoginController {
   public function view() {
      $v = View::getInstance();
      $c = $v->getCollectionObject();
      if (is_object($c)) {
         $cID = $c->getCollectionID();
         if($cID) { 
            $this->forward($cID); // set the intended url
         }
      }
      parent::view();
      $u = new User();
      $logged = $u->isLoggedIn();
      if(!$logged && FORBIDDEN_SHOW_LOGIN) { //if they are not logged in, and we show guests the login...
         $this->render('/login');


See the line that says '$this->forward($cID);'? That line tells the login controller where to send the user after logging in if they were trying to access a protected page. 5.6 actually extends the login controller and can therefore define a cID to forward to after a successful login.

5.7.3.1:
class PageForbidden extends Controller {
   protected $viewPath = '/frontend/page_forbidden';
   public function view() {
      $u = new User();
        if (!$u->isRegistered()) { //if they are not logged in, and we show guests the login...
         $this->redirect('/login');
      }
   }
}


Unlike 5.6, 5.7's page_forbidden doesn't extend the login controller and doesn't attempt to define a forwarding url. In fact, it only does a basic redirect to login.

I'm now trying to determine the best way to re-introduce this functionality. Will post back here if I come up with a viable solution!
dwhillier replied on at Permalink Reply
dwhillier
Submitted a pull request to 5.7 github repo for this:https://github.com/concrete5/concrete5-5.7.0/pull/1997...
jeromeb replied on at Permalink Reply
Thanks a lot but I'm sorry to say that I have not understood most that you said. Does this mean that you have a fix already? Can you tell me (as an ordinary guy with no coding knowledge) how to apply the fix?
dwhillier replied on at Permalink Reply
dwhillier
Oops, sorry man!

If you navigate to the page in the github repo, you can copy the resulting page of code by clicking on the 'Raw' button. Then open up the corresponding page in your 'concrete' folder and replace the entire contents with what you copied.

Github link:https://github.com/concrete5/concrete5-5.7.0/blob/590976744528fdb57f...

Corresponding C5 page: /concrete/src/Routing/DispatcherRouteCallback.php

Andrew Embler (C5 primary developer) made some modifications for better integration.

Let me know if you need more details!
jeromeb replied on at Permalink Reply
Thanks a bunch for the help.

Just to make sure that I understand your advice, do you mean to say that i can create a DispatcherRouteCallback.php file that contains the code from the github repo, save and overwrite the existing file in the directory /concrete/src/Routing/, and after which the login destination page will change to whatever the original link is?

I just want to make sure before I try. I'm excited to hear your confirmation.
dwhillier replied on at Permalink Reply
dwhillier
That is correct. I haven't tested wth Andrews modifications, but the code
looks sound!

On Saturday, February 21, 2015, concrete5 Community <
discussions@concretecms.com> wrote:
jeromeb replied on at Permalink Reply
I just tried your suggestion and afterwards I'm unable to access any of my pages. On chrome it says "This webpage has a redirect loop".

I assume I followed everything that you said correctly but do you mind checking my php file if there's anything wrong?

Thanks again!
dwhillier replied on at Permalink Reply
dwhillier
That's interesting, it's working for me. Just retried myself using the code from Github. Did you try clearing your C5 cache?

Were you on the latest 5.7.3.1?
dwhillier replied on at Permalink Reply
dwhillier
Nope, don't mind checking.
jeromeb replied on at Permalink Reply
Thanks again for replying.

After I modify the php file i'm unable to go to any page including the admin page to clear the cache. Is there any way to do this?

I'm running version 5.7.2.1. My installation is not in the public_html directory, but inside the "public_html/members" directory and all my pages are password protected. Do you think that this is causing the problem?

Another request, can you send me your PHP file and I'll see if it works for me?
dwhillier replied on at Permalink Reply 1 Attachment
dwhillier
It is possible that the update between, 5.7.2.x and 5.7.3.x might have changed things enough to throw off the updated code for this behaviour.

I have attached my version for you to try.

If you would like, feel free to zip up your site files and site database and I can give it a quick go locally.

You have to rename the file back to .php from .txt.
jeromeb replied on at Permalink Reply
Thanks for sending your file. I just tried it, and it's the same problem.

Not sure how I can send my files to you. Instead, would you be willing to check a sample page on my site and could that help for you to see why the php file isn't doing what it's supposed to do?