Azure AD ISAUTHENTICATITATED在ReactJS应用程序中的另一个选项卡中复制主页URL后会变得错误。

发布于 2025-01-27 16:19:31 字数 404 浏览 3 评论 0原文

我在ReactJS应用程序中创建了Azure AD身份验证。每当我们登录它时,它都可以正常工作。但是,登录并尝试在另一个选项卡中复制主页URL后,它并未将其重定向到所需的页面。我委托记录了术语化的,它显示为假。主页实际上是登录页面。

这是我的主页代码段,以重定向到仪表板:

    useEffect(() => {

        console.log("isAuthenticated", isAuthenticated);
        if(isAuthenticated){
          navigate('dashboard');
        }

  }, [isAuthenticated])

是否有任何办法在另一个选项卡中以符号为true。

如果用户已经登录,

I have created an Azure AD authentication in ReactJs application. It is working fine whenever we are logging into it. However, after login and try to copy the home page url in another tab, it is not redirecting to the desired page. I console logged the isAuthenticated, it is showing as false. Home page is the login page actually.

Here is my code snippet of Home page to redirect to the Dashboard :

    useEffect(() => {

        console.log("isAuthenticated", isAuthenticated);
        if(isAuthenticated){
          navigate('dashboard');
        }

  }, [isAuthenticated])

Is there any way out to get isAuthenticated as true in another tab if the user is already logged in.

Thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨光如昨 2025-02-03 16:19:31

JUUNAS在评论中所述的正确,您可能正在使用sessionstorage,这是您遇到此问题的原因。

sessionStorage关闭浏览器选项卡或窗口时自动删除数据的其中,本地存储中的数据没有默认到期。仅当您直接通过浏览器设置或通过JavaScript代码直接从本地存储中删除该数据时才删除。

这意味着即使在关闭特定选项卡或浏览器窗口之后,本地存储中的数据仍然存在,

以获取更多信息,您可以参考此 link

As juunas stated in the comment is correct, You might be using sessionStorage that is reason you facing this issue.

In sessionStorage where data is automatically deleted when a browser tab or window is closed, data in local storage has no default expiry. It's only deleted if you manually delete that data from the local storage either directly, via browser settings, or through your JavaScript code.

That means that data in a local storage persists even after a particular tab or browser window is closed

for more information you can refer this Link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文