API: add login username in SendLoginLogCommand (#28544) (#28545)

* API: add login username in Login actions

* LoginUser -> LoginUsername

* fix test

(cherry picked from commit 65b5086a59)

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2020-10-26 18:52:48 +02:00
committed by GitHub
co-authored by Agnès Toulet
parent c933d58893
commit 9b3981fb3c
3 changed files with 14 additions and 11 deletions
+6 -5
View File
@@ -171,11 +171,12 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext, cmd dtos.LoginCommand) Res
err = errors.New(response.errMessage)
}
hs.SendLoginLog(&models.SendLoginLogCommand{
ReqContext: c,
LogAction: action,
User: user,
HTTPStatus: response.status,
Error: err,
ReqContext: c,
LogAction: action,
User: user,
LoginUsername: cmd.User,
HTTPStatus: response.status,
Error: err,
})
}()
+1
View File
@@ -652,6 +652,7 @@ func TestLoginPostSendLoginLog(t *testing.T) {
cmd := testReceiver.cmd
assert.Equal(t, c.cmd.LogAction, cmd.LogAction)
assert.Equal(t, "admin", cmd.LoginUsername)
assert.Equal(t, c.cmd.HTTPStatus, cmd.HTTPStatus)
assert.Equal(t, c.cmd.Error, cmd.Error)