init
This commit is contained in:
29
internal/app/flash.go
Normal file
29
internal/app/flash.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/yourorg/ntfywui/internal/security"
|
||||
)
|
||||
|
||||
func (s *Server) setFlash(w http.ResponseWriter, r *http.Request, msg string) {
|
||||
sess, ok := s.sessions.Get(r)
|
||||
if !ok {
|
||||
sess = &security.Session{}
|
||||
}
|
||||
sess.Flash = msg
|
||||
_ = s.sessions.Save(w, sess)
|
||||
}
|
||||
|
||||
func (s *Server) popFlash(w http.ResponseWriter, r *http.Request) string {
|
||||
sess, ok := s.sessions.Get(r)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
msg := sess.Flash
|
||||
if msg != "" {
|
||||
sess.Flash = ""
|
||||
_ = s.sessions.Save(w, sess)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
Reference in New Issue
Block a user