Trigger Login Hooks with OAuth (#10061)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
f36b66fb9a
Коммит
ccb9429f51
22
app/oauth.go
22
app/oauth.go
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/einterfaces"
|
"github.com/mattermost/mattermost-server/einterfaces"
|
||||||
"github.com/mattermost/mattermost-server/mlog"
|
"github.com/mattermost/mattermost-server/mlog"
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
|
"github.com/mattermost/mattermost-server/plugin"
|
||||||
"github.com/mattermost/mattermost-server/store"
|
"github.com/mattermost/mattermost-server/store"
|
||||||
"github.com/mattermost/mattermost-server/utils"
|
"github.com/mattermost/mattermost-server/utils"
|
||||||
)
|
)
|
||||||
@@ -558,6 +559,27 @@ func (a *App) LoginByOAuth(service string, userData io.Reader, teamId string) (*
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||||
|
var rejectionReason string
|
||||||
|
pluginContext := a.PluginContext()
|
||||||
|
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||||
|
rejectionReason = hooks.UserWillLogIn(pluginContext, user)
|
||||||
|
return rejectionReason == ""
|
||||||
|
}, plugin.UserWillLogInId)
|
||||||
|
|
||||||
|
if rejectionReason != "" {
|
||||||
|
return nil, model.NewAppError("LoginByOAuth", "Login rejected by plugin: "+rejectionReason, nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
a.Srv.Go(func() {
|
||||||
|
pluginContext := a.PluginContext()
|
||||||
|
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||||
|
hooks.UserHasLoggedIn(pluginContext, user)
|
||||||
|
return true
|
||||||
|
}, plugin.UserHasLoggedInId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user