redirecting back to page after authentication

  • fouadtarabolsi-1322238372751736897

    FouadTarabolsi

    3 months 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.
  • lucasg-1322261786954829936

    Lucas G

    3 months ago

    Pass the current URL as a parameter to the login page
    ๐Ÿ‘1
  • And on successful login, redirect back to that page
  • fouadtarabolsi-1322279226291916801

    FouadTarabolsi

    3 months 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
  • lucasg-1322287109586944081

    Lucas G

    3 months 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-1322297996498440292

    FouadTarabolsi

    3 months 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"
    )
  • fouadtarabolsi-1322298369112019016

    FouadTarabolsi

    3 months ago

    1322298369221328916-image.png
  • fouadtarabolsi-1322298810004934707

    FouadTarabolsi

    3 months 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
  • lucasg-1322299004960378971

    Lucas G

    3 months 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.