mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
always delete session cookie even if db delete fails
This commit is contained in:
parent
91bd908e03
commit
a1b3986532
@ -20,3 +20,5 @@ services:
|
||||
-config.file=/etc/promtail/docker-config.yaml
|
||||
networks:
|
||||
- loki
|
||||
depends_on:
|
||||
- loki
|
||||
|
@ -121,18 +121,10 @@ func (s *UserAuthTokenServiceImpl) SignOutUser(c *models.ReqContext) error {
|
||||
hashedToken := hashToken(unhashedToken)
|
||||
|
||||
sql := `DELETE FROM user_auth_token WHERE auth_token = ?`
|
||||
res, err := s.SQLStore.NewSession().Exec(sql, hashedToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := s.SQLStore.NewSession().Exec(sql, hashedToken)
|
||||
|
||||
affected, _ := res.RowsAffected()
|
||||
if affected > 0 {
|
||||
s.writeSessionCookie(c, "", -1)
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to delete session")
|
||||
s.writeSessionCookie(c, "", -1)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *UserAuthTokenServiceImpl) CreateToken(userId int64, clientIP, userAgent string) (*userAuthToken, error) {
|
||||
|
@ -73,7 +73,7 @@ func TestUserAuthToken(t *testing.T) {
|
||||
|
||||
Convey("signing out an none existing session should return an error", func() {
|
||||
httpreq := &http.Request{Header: make(http.Header)}
|
||||
httpreq.AddCookie(&http.Cookie{Name: userAuthTokenService.Cfg.LoginCookieName, Value: "missing-session-cookie"})
|
||||
httpreq.AddCookie(&http.Cookie{Name: userAuthTokenService.Cfg.LoginCookieName, Value: ""})
|
||||
|
||||
ctx := &models.ReqContext{Context: &macaron.Context{
|
||||
Req: macaron.Request{Request: httpreq},
|
||||
|
Loading…
Reference in New Issue
Block a user