mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
79cef75fed
commit
beb85f413a
@ -36,7 +36,7 @@ func LoginView(c *middleware.Context) {
|
|||||||
viewData.Settings["disableLoginForm"] = setting.DisableLoginForm
|
viewData.Settings["disableLoginForm"] = setting.DisableLoginForm
|
||||||
|
|
||||||
if loginError, ok := c.Session.Get("loginError").(string); ok {
|
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
|
viewData.Settings["loginError"] = loginError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,8 @@ type SessionStore interface {
|
|||||||
Set(interface{}, interface{}) error
|
Set(interface{}, interface{}) error
|
||||||
// Get gets value by given key in session.
|
// Get gets value by given key in session.
|
||||||
Get(interface{}) interface{}
|
Get(interface{}) interface{}
|
||||||
|
// Delete deletes a key from session.
|
||||||
|
Delete(interface{}) interface{}
|
||||||
// ID returns current session ID.
|
// ID returns current session ID.
|
||||||
ID() string
|
ID() string
|
||||||
// Release releases session resource and save data to provider.
|
// Release releases session resource and save data to provider.
|
||||||
@ -128,6 +130,13 @@ func (s *SessionWrapper) Get(k interface{}) interface{} {
|
|||||||
return nil
|
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 {
|
func (s *SessionWrapper) ID() string {
|
||||||
if s.session != nil {
|
if s.session != nil {
|
||||||
return s.session.ID()
|
return s.session.ID()
|
||||||
|
Loading…
Reference in New Issue
Block a user