[英]reset user login session in angularjs
I store user auth info and token in a cookie
locally for my angular/typescript
SPA. 我将我的
angular/typescript
SPA的用户身份验证信息和令牌存储在本地的cookie
。 Cookie expires after a certain time I have set. Cookie会在我设置的一定时间后过期。 How do I reset expiration while user's activity?
在用户活动时如何重置到期时间? (session on the server is reset on users requests)
(服务器上的会话根据用户请求重置)
I mean what would be the best way, so I don't code some stupid stuff. 我的意思是最好的方法,所以我不会编写一些愚蠢的东西。
Thank you 谢谢
I assume you do your authentication and generation of the cookie on the server and your angular side authentication is located in a service. 我假设您在服务器上进行身份验证和cookie的生成,并且角度身份验证位于服务中。
One way to achieve what you are looking for is to create a method in your client side service to send a request to a known end point of the server which would refresh the cookie. 一种实现您要寻找的方法的方法是在客户端服务中创建一个方法,以将请求发送到服务器的已知端点,该请求将刷新cookie。 This server endpoint will refresh the cookie and will return a HTTP 200 code.
该服务器端点将刷新cookie,并返回HTTP 200代码。
Once you have this code in place, you can call it when the user interact with the application (ex navigation across views via $locationChangeStart, $routeChangeStart
etc). 一旦有了此代码,就可以在用户与应用程序交互时调用它(通过
$locationChangeStart, $routeChangeStart
等在视图之间进行导航)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.