纯 JavaScript 中的 Zendesk 注销功能
我想实现一个注销功能。当用户单击“注销”时,我想结束其会话并重定向到另一个页面。遗憾的是,我仅限于 JavaScript。
编辑: 将其移至 Zendesk,因为他们似乎有远程身份验证 API。
感谢所有回答的人。
I want to implement a logout function. When a user clicks Logout
, I want to end their session and redirect to another page. Sadly, I am limited to only JavaScript.
EDIT:
Moving this over to Zendesk because it seems like they have a Remote Authentication API.
Thank you to all the people who answered.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的登录会话状态存储在不是
httpOnly
< 的 Cookie 中/a>,您只需将登录 cookie 的到期日期设置为过去即可删除它。例如,使用 这个 cookie 库:然后你可以执行
location.assign( '/logged_out_page.html');
重定向到另一个页面。Assuming your login session state is stored in a cookie that isn't
httpOnly
, you can simply delete the login cookie by setting its expiry date to a the past. For example, using this cookie library:Then you can just do a
location.assign('/logged_out_page.html');
to redirect to another page.这取决于您使用的服务器技术。
假设有一个 logout.aspx 页面。您可以只对该页面执行 AJAX 请求来切换会话,或者删除应用程序可能用于缓存身份验证的 cookie,然后像这样进行重定向:
window.location = "http ://www.mysite.com/logout.aspx";
更新
我刚刚在 SO 上找到了这篇文章,应该有所帮助(这并不容易):
https://stackoverflow.com/questions/3237476/zendesk-remote-auth-using-java< /a>
It depends on what server technology you're using.
Let's say there's a logout.aspx page. You could just do an AJAX request to that page to zap the session, or delete a cookie that the application might be using to cache authentication, then redirect like so:
window.location = "http://www.mysite.com/logout.aspx";
UPDATE
I just found this post on SO that should help (that wasn't easy):
https://stackoverflow.com/questions/3237476/zendesk-remote-auth-using-java