Commit beb85f41 by Daniel Lee

oauth: delete session key instead of set to empty

Adds the Delete function to the Session wrapper so that the Macaron
function for deleting keys from a Session can be used.

https://go-macaron.com/docs/middlewares/session#implement-provider-interface
parent 79cef75f
......@@ -36,7 +36,7 @@ func LoginView(c *middleware.Context) {
viewData.Settings["disableLoginForm"] = setting.DisableLoginForm
if loginError, ok := c.Session.Get("loginError").(string); ok {
c.Session.Set("loginError", "") // TODO: is there a proper way to delete a session var?
c.Session.Delete("loginError")
viewData.Settings["loginError"] = loginError
}
......
......@@ -93,6 +93,8 @@ type SessionStore interface {
Set(interface{}, interface{}) error
// Get gets value by given key in session.
Get(interface{}) interface{}
// Delete deletes a key from session.
Delete(interface{}) interface{}
// ID returns current session ID.
ID() string
// Release releases session resource and save data to provider.
......@@ -128,6 +130,13 @@ func (s *SessionWrapper) Get(k interface{}) interface{} {
return nil
}
func (s *SessionWrapper) Delete(k interface{}) interface{} {
if s.session != nil {
return s.session.Delete(k)
}
return nil
}
func (s *SessionWrapper) ID() string {
if s.session != nil {
return s.session.ID()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment