GAE Go在注销时执行其他操作。

huangapple go评论102阅读模式
英文:

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))
}

huangapple
  • 本文由 发表于 2015年3月19日 00:18:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/29127242.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定