OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Redirecting to the requested page after login

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Redirecting to the requested page after login

Postby selahi » Thu Sep 20, 2007 1:53 am

Dear all,

In our Journal system, a user can see abstract but to view the full article user has to be logged in otherwise get redirected to the login page. But once user logs in, I want to redirect the user to the page it was on before getting redirected to login page instead of default user home page. Any ideas?

Salman
selahi
 
Posts: 28
Joined: Mon Nov 20, 2006 9:09 am

Re: Redirecting to the requested page after login

Postby asmecher » Thu Sep 20, 2007 7:51 am

Hi Salman,

That's the way OJS should behave. When you get redirected to the login page, do you see a "source" parameter in the URL?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8315
Joined: Wed Aug 10, 2005 12:56 pm

Re: Redirecting to the requested page after login

Postby selahi » Thu Sep 20, 2007 8:01 am

Hi Alec,

Thank you very much for your reply to RT question. No, there is no source parameter in the URL

I get redirected from : https://172.16.0.82/ojs-2.1.1/index.php/FRJ/issue/current/showToc

to: https://172.16.0.82/ojs-2.1.1/index.php/FRJ/login

Best regards,

Salman
selahi
 
Posts: 28
Joined: Mon Nov 20, 2006 9:09 am

Re: Redirecting to the requested page after login

Postby asmecher » Thu Sep 20, 2007 8:35 am

Hi Salman,

Hmm -- it sounds to me like your web server isn't providing PHP with the REQUEST_URI parameter. See classes/security/Validation.inc.php:
Code: Select all
        /**
         * Redirect to the login page, appending the current URL as the source.
         */
        function redirectLogin($message = null, $args = array()) {

                if (isset($_SERVER['REQUEST_URI'])) {
                        $args['source'] = $_SERVER['REQUEST_URI'];
                }
                if ($message !== null) {
                        $args['loginMessage'] = $message;
                }

                Request::redirect(null, null, 'login', null, null, $args);
        }
This code uses the $_SERVER['REQUEST_URI'] call to determine what the current URI is, and it doesn't seem to be getting anything. You might try looking through the list of server variables to see if anything else can be used instead. To do this, run the following script:
Code: Select all
<?php print_r($_SERVER); ?>
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8315
Joined: Wed Aug 10, 2005 12:56 pm

Re: Redirecting to the requested page after login

Postby selahi » Thu Sep 20, 2007 9:04 am

Hi Alec,

My server is providing PHP with REQUEST_URI with /ojs-2.1.1/php_info.php when use php_info(); to see the variables.

However, there is a weired thing which I have noted few times earlier as well, that am I using an older version of OJS, which I am sure not cuz it says OJS-2.1.1 but the thing which makes me think is that few weeks ago I had to use a patch for email functionality, then had to use patch for making Abstracts, which you might remember we discussed two days ago.

And now the function code you have send in your reply is different from the one I have got which is:

Code: Select all
/**
    * Redirect to the login page, appending the current URL as the source.
    */
   function redirectLogin() {
      if (Validation::isLoggedIn()){
            if (isset($_SERVER['REQUEST_URI'])) {
            Request::redirect(null, 'user', 'registerAsAuthor');
            } else {
                  Request::redirect(null, 'login');
            }
      }
      else{
         Request::redirect(null, 'login');
      }
            
   }



However, I replaced the code above with the code you sent and now this exception is being thrown:

404 Not Found
Stack Trace:
File: (unknown) line (unknown)
Function: Handler::index(Array(0))

File: /usr/local/apache2/htdocs/ojs-2.1.1/index.php line 50
Function: call_user_func(Array(2), Array(0))

File: /usr/local/apache2/htdocs/ojs-2.1.1/index.php line 57
Function: handleRequest()

what do you think now?

Best regards,

Salman
selahi
 
Posts: 28
Joined: Mon Nov 20, 2006 9:09 am

Re: Redirecting to the requested page after login

Postby selahi » Fri Sep 21, 2007 2:43 am

Hi Alec,

OK,I got it... it was me, I did change this class and completely forgot to put any comments... It's redirecting to the requested page now after logging in, really sorry to bother you. However, my worry is still there because the original code I have got here with me (from the zip file I used to extract the version of OJS i am using) is still different from the one you have sent:

Original code which I downloaded:

Code: Select all
/**
    * Redirect to the login page, appending the current URL as the source.
   */
   function redirectLogin() {
      if (isset($_SERVER['REQUEST_URI'])) {
         Request::redirect(null, 'login', null, null, array('source' => $_SERVER['REQUEST_URI']));
      } else {
         Request::redirect(null, 'login');
      }
   }


you can see this is different from the one you sent so what you say about this... and sorry again about the previous confusion.

Best regards,

Salman
selahi
 
Posts: 28
Joined: Mon Nov 20, 2006 9:09 am

Re: Redirecting to the requested page after login

Postby asmecher » Fri Sep 21, 2007 7:59 am

Hi Salman,

The one I originally quoted is from CVS, which has changed a little from the version released with 2.1.1, which is what you've quoted. Either should behave as you described in your original request.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8315
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 7 guests