module_index_act_logout.go 414 B

123456789101112131415161718192021
  1. package modules
  2. import (
  3. "golang-fave/engine/wrapper"
  4. )
  5. func (this *Modules) RegisterAction_IndexUserLogout() *Action {
  6. return this.newAction(AInfo{
  7. Mount: "index-user-logout",
  8. WantUser: true,
  9. }, func(wrap *wrapper.Wrapper) {
  10. // Reset session var
  11. wrap.S.SetInt("UserId", 0)
  12. // Delete session file
  13. _ = wrap.S.Destroy()
  14. // Navigate to login page
  15. wrap.Write(`window.location='/cp/';`)
  16. })
  17. }