mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
API: replace SendLoginLogCommand with LoginHook (#28777)
* API: replace SendLoginLogCommand with LoginHook * LoginInfo: Query -> LoginUsername
This commit is contained in:
@@ -8,8 +8,11 @@ import (
|
||||
|
||||
type IndexDataHook func(indexData *dtos.IndexViewData, req *models.ReqContext)
|
||||
|
||||
type LoginHook func(loginInfo *models.LoginInfo, req *models.ReqContext)
|
||||
|
||||
type HooksService struct {
|
||||
indexDataHooks []IndexDataHook
|
||||
loginHooks []LoginHook
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -29,3 +32,13 @@ func (srv *HooksService) RunIndexDataHooks(indexData *dtos.IndexViewData, req *m
|
||||
hook(indexData, req)
|
||||
}
|
||||
}
|
||||
|
||||
func (srv *HooksService) AddLoginHook(hook LoginHook) {
|
||||
srv.loginHooks = append(srv.loginHooks, hook)
|
||||
}
|
||||
|
||||
func (srv *HooksService) RunLoginHook(loginInfo *models.LoginInfo, req *models.ReqContext) {
|
||||
for _, hook := range srv.loginHooks {
|
||||
hook(loginInfo, req)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user