How can I do this in Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lad

    #1

    How can I do this in Python?

    Hi,
    I have a web program and a user can have access to a page only after he
    logged in.
    So, the program comes with a Login form and the user logins.But I do
    not know how to return the user back to where he came from, after a
    successful login.

    Something like this:

    PageWhereUserMu stBeLogin -------->UserSigned----->-

    ^------<---------------------------------------------------<----|


    Thank you for help

    L.

  • David  Wahler

    #2
    Re: How can I do this in Python?

    Lad wrote:[color=blue]
    > Hi,
    > I have a web program and a user can have access to a page only after he
    > logged in.
    > So, the program comes with a Login form and the user logins.But I do
    > not know how to return the user back to where he came from, after a
    > successful login.
    >
    > Something like this:
    >
    > PageWhereUserMu stBeLogin -------->UserSigned----->-
    >
    > ^------<---------------------------------------------------<----|
    >
    >
    > Thank you for help
    >
    > L.[/color]

    You'll need to either use a hidden form field or check the HTTP
    "Referer" header to determine the page the user was on. Then, just use
    an HTTP redirect to send them back to that page.

    Are you using a particular web application framework, or separate CGI
    scripts?

    -- David

    Comment

    • Steve Holden

      #3
      Re: How can I do this in Python?

      David Wahler wrote:[color=blue]
      > Lad wrote:
      >[color=green]
      >>Hi,
      >>I have a web program and a user can have access to a page only after he
      >>logged in.
      >>So, the program comes with a Login form and the user logins.But I do
      >>not know how to return the user back to where he came from, after a
      >>successful login.
      >>
      >>Something like this:
      >>
      >>PageWhereUser MustBeLogin -------->UserSigned----->-
      >>
      >>^------<---------------------------------------------------<----|
      >>
      >>
      >>Thank you for help
      >>
      >>L.[/color]
      >
      >
      > You'll need to either use a hidden form field or check the HTTP
      > "Referer" header to determine the page the user was on. Then, just use
      > an HTTP redirect to send them back to that page.
      >
      > Are you using a particular web application framework, or separate CGI
      > scripts?
      >[/color]
      Another alternative might be to serve a script that sent the browser
      back 2 pages in its history, as long as server state hasn't changed in
      the meantime.

      regards
      Steve
      --
      Steve Holden +44 150 684 7255 +1 800 494 3119
      Holden Web LLC www.holdenweb.com
      PyCon TX 2006 www.python.org/pycon/

      Comment

      • Leif K-Brooks

        #4
        Re: How can I do this in Python?

        Steve Holden wrote:[color=blue]
        > Another alternative might be to serve a script that sent the browser
        > back 2 pages in its history, as long as server state hasn't changed in
        > the meantime.[/color]

        What about users with JavaScript disabled?

        Comment

        • jgardner@jonathangardner.net

          #5
          Re: How can I do this in Python?

          I strongly suggest using redirect as David Wahler suggested.

          A note, Mozilla type browsers don't do an excellent job sending
          referer. You can't really trust that header anymore. If you want to go
          back after login, either:

          (1) Render the login page INSTEAD of the normal content at the same
          url. Form submission would go back to the same page not requiring a
          login; plus, you could pick up the URL and paramters on the login page.

          (2) Have the page requiring login redirect with extra parameters that
          describe the page URL and the parameters needed to access it properly.
          HOWEVER, you need to be careful that you don't allow any old URL there,
          because someone else could have your logged in user redirect to their
          site.

          Comment

          • Lad

            #6
            Re: How can I do this in Python?

            Can you please explain in more details (1) choice?
            Thanks
            Regards,
            L

            Comment

            • Kent Johnson

              #7
              Re: How can I do this in Python?

              Lad wrote:[color=blue]
              > Can you please explain in more details (1) choice?[/color]

              If you are using CGI you might be interested in the VoidSpace logintools which seems to handle much of this process. See
              http://www.voidspace.org.uk/python/l...ogin-no-access

              Kent

              Comment

              Working...