gpt4 book ai didi

reactjs - AWS Amplify 用户 session 不会在 ReactJS 中过期

转载 作者:行者123 更新时间:2023-12-05 03:02:35 24 4
gpt4 key购买 nike

我正在使用 ReactJS 创建一个无服务器网站,AWS Amplify 用于身份验证,AWS Cognito 用于用户池。

如果用户在网站上未活跃一个小时(或者如果他们关闭选项卡并在一个小时内不返回该网站),我正在尝试让该网站将用户注销。但是,即使我第二天访问该站点,我的用户仍会继续登录。

我在 Amplify 的文档中读到,Amplify 会在 token 过期时自动刷新 token ,但我找不到禁用它的方法。

我将不胜感激任何帮助。我不太确定如何解决这个问题。

谢谢。

最佳答案

根据 cognito 文档 ( https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html#amazon-cognito-user-pools-using-the-refresh-token )

By default, the refresh token expires 30 days after your app user signs in to your user pool. When you create an app for your user pool, you can set the app's refresh token expiration (in days) to any value between 1 and 3650.

如果您没有更改默认设置,则 Amplify 将能够刷新 token 30 天。即使改成最小值1,Amplify也能刷新24小时。

为了跟踪预期的 session 过期时间,即使用户关闭了浏览器,您也需要将该数据存储在数据库中。您可以使用 lambda 测试该值,然后根据响应在必要时使用 Auth.signOut()

关于reactjs - AWS Amplify 用户 session 不会在 ReactJS 中过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54712389/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com