英文:
GAE Go perform additional actions on logout
问题
当用户通过user.LogoutURL路径从GAE应用程序注销时,我希望在他们注销时执行其他操作。
我如何使用特定的处理程序覆盖它(例如:https://cloud.google.com/appengine/docs/go/users/#Go_User_authentication_in_Go),并执行所需的注销操作?或者我如何检测用户正在注销,然后执行我想要的操作?
英文:
When a user logs out of a GAE app via the user.LogoutURL path, I want to perform additional actions when they log out.
How can I override that with a specific handler (like so: https://cloud.google.com/appengine/docs/go/users/#Go_User_authentication_in_Go) and still perform the required logout actions? Or how can I detect a user is logging out and then perform the actions I want?
答案1
得分: 4
你可以创建自己的注销处理程序,并重定向到 user.LogoutURL
。
func logoutHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
// 在这里执行你想要的操作。
http.Redirect(w, r, users.LogoutURL(c))
}
英文:
What you can do, is create your own logout handler, and redirect to the user.LogoutURL
.
func logoutHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
// do what you want to do here.
http.Redirect(w, r, users.LogoutURL(c))
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论