API: add login username in SendLoginLogCommand (#28544)

* API: add login username in Login actions

* LoginUser -> LoginUsername

* fix test
This commit is contained in:
Agnès Toulet 2020-10-26 15:47:01 +01:00 committed by GitHub
parent 96e6524a7d
commit 65b5086a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 11 deletions

View File

@ -178,11 +178,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,
})
}()

View File

@ -687,6 +687,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)

View File

@ -66,12 +66,13 @@ type DeleteAuthInfoCommand struct {
}
type SendLoginLogCommand struct {
ReqContext *ReqContext
LogAction string
User *User
ExternalUser *ExternalUserInfo
HTTPStatus int
Error error
ReqContext *ReqContext
LogAction string
User *User
ExternalUser *ExternalUserInfo
LoginUsername string
HTTPStatus int
Error error
}
// ----------------------