redirecting back to page after authentication

  • FouadTarabolsi

    18 days ago

    Hi there,
    I am still new to toddle, but I am happy on how fast I am progressing.
    I created many pages in my app including the login page. login page successfully redirects to the main page after authentication.

    I also was able to redirect the other pages to the login page if the user is not authenticated.

    now i am struggling with redirecting the user back to the page he requested instead of going to the default home page.

    I tried asking the AI and went through a few discord posts. i was not able to sort it out.
  • Lucas G

    18 days ago

    Pass the current URL as a parameter to the login page
    👍1
  • And on successful login, redirect back to that page
  • FouadTarabolsi

    18 days ago

    this is what i was trying to figure out how to do it , is it ?redirect= or ?redirect_to= or ?redirect_url=
    while researching i found many answers but non worked
  • Lucas G

    18 days ago

    Any would work. You set it as a URL parameter on the login page
  • When you redirect to the login page you pass it in the URL
  • Like mydomain.com/login?redirect=mydomain.com/current-page
  • And on the login page, you check if there’s a url. If so, redirect to it, otherwise go to home page
  • The parameter can be anything though, that part doesn’t matter.
  • FouadTarabolsi

    18 days ago

    thanks, I was able to figure out where the issue is. I was able to successfully implement it by doing configuration this function on the click event in the login page:
    Default to(
    Decode URI Component(
    Get(
    Get(
    Parse URL(Current URL()),
    "searchParams"
    ),
    "redirect"
    )
    ),
    "/home"
    )
  • /attachments/1322238372751736897/1322298369221328916/image.png

    FouadTarabolsi

    18 days ago

    image.png
  • FouadTarabolsi

    18 days ago

    @Lucas G now it is clear that redirect, redirect_to or what ever i chose does not matter as long I am consistent int he name on both pages.
    thank you very much
  • Lucas G

    18 days ago

    Close but there’s an even easier way
  • On your login page on the top right, where you set the page meta data, you can set URL parameters
  • You can set your query parameter there and you won’t even need the formula
    👍1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.