application lifecycle event support

This commit is contained in:
Marcus Efraimsson
2018-10-26 13:57:31 +02:00
parent cfb061ddab
commit 9edaa3fa8c
5 changed files with 82 additions and 12 deletions

View File

@@ -2,7 +2,9 @@ package login
import (
"errors"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/lifecycle"
m "github.com/grafana/grafana/pkg/models"
)
@@ -18,9 +20,11 @@ var (
ErrGettingUserQuota = errors.New("Error getting user quota")
)
func Init() {
bus.AddHandler("auth", AuthenticateUser)
loadLdapConfig()
func init() {
lifecycle.AddListener(lifecycle.ApplicationStarting, func() {
bus.AddHandler("auth", AuthenticateUser)
loadLdapConfig()
})
}
func AuthenticateUser(query *m.LoginUserQuery) error {