[MM-54434] Use job.Logger to capture ldap logs (#24493)

Этот коммит содержится в:
Ben Schumacher
2023-10-06 22:43:21 +02:00
коммит произвёл GitHub
родитель afaf41b587
Коммит aad25be4e1
50 изменённых файлов: 385 добавлений и 426 удалений

Просмотреть файл

@@ -22,13 +22,13 @@ func (a *App) SyncLdap(c *request.Context, includeRemovedMembers bool) {
if license := a.Srv().License(); license != nil && *license.Features.LDAP {
if !*a.Config().LdapSettings.EnableSync {
mlog.Error("LdapSettings.EnableSync is set to false. Skipping LDAP sync.")
c.Logger().Error("LdapSettings.EnableSync is set to false. Skipping LDAP sync.")
return
}
ldapI := a.Ldap()
if ldapI == nil {
mlog.Error("Not executing ldap sync because ldap is not available")
c.Logger().Error("Not executing ldap sync because ldap is not available")
return
}
ldapI.StartSynchronizeJob(c, false, includeRemovedMembers)
@@ -89,7 +89,7 @@ func (a *App) GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSe
return groups, total, nil
}
func (a *App) SwitchEmailToLdap(email, password, code, ldapLoginId, ldapPassword string) (string, *model.AppError) {
func (a *App) SwitchEmailToLdap(c *request.Context, email, password, code, ldapLoginId, ldapPassword string) (string, *model.AppError) {
if a.Srv().License() != nil && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
return "", model.NewAppError("emailToLdap", "api.user.email_to_ldap.not_available.app_error", nil, "", http.StatusForbidden)
}
@@ -112,20 +112,20 @@ func (a *App) SwitchEmailToLdap(email, password, code, ldapLoginId, ldapPassword
return "", model.NewAppError("SwitchEmailToLdap", "api.user.email_to_ldap.not_available.app_error", nil, "", http.StatusNotImplemented)
}
if err := ldapInterface.SwitchToLdap(user.Id, ldapLoginId, ldapPassword); err != nil {
if err := ldapInterface.SwitchToLdap(c, user.Id, ldapLoginId, ldapPassword); err != nil {
return "", err
}
a.Srv().Go(func() {
if err := a.Srv().EmailService.SendSignInChangeEmail(user.Email, "AD/LDAP", user.Locale, a.GetSiteURL()); err != nil {
mlog.Error("Could not send sign in method changed e-mail", mlog.Err(err))
c.Logger().Error("Could not send sign in method changed e-mail", mlog.Err(err))
}
})
return "/login?extra=signin_change", nil
}
func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (string, *model.AppError) {
func (a *App) SwitchLdapToEmail(c *request.Context, ldapPassword, code, email, newPassword string) (string, *model.AppError) {
if a.Srv().License() != nil && !*a.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer {
return "", model.NewAppError("ldapToEmail", "api.user.ldap_to_email.not_available.app_error", nil, "", http.StatusForbidden)
}
@@ -144,7 +144,7 @@ func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (
return "", model.NewAppError("SwitchLdapToEmail", "api.user.ldap_to_email.not_available.app_error", nil, "", http.StatusNotImplemented)
}
if err := ldapInterface.CheckPasswordAuthData(*user.AuthData, ldapPassword); err != nil {
if err := ldapInterface.CheckPasswordAuthData(c, *user.AuthData, ldapPassword); err != nil {
return "", err
}
@@ -164,16 +164,16 @@ func (a *App) SwitchLdapToEmail(ldapPassword, code, email, newPassword string) (
a.Srv().Go(func() {
if err := a.Srv().EmailService.SendSignInChangeEmail(user.Email, T("api.templates.signin_change_email.body.method_email"), user.Locale, a.GetSiteURL()); err != nil {
mlog.Error("Could not send sign in method changed e-mail", mlog.Err(err))
c.Logger().Error("Could not send sign in method changed e-mail", mlog.Err(err))
}
})
return "/login?extra=signin_change", nil
}
func (a *App) MigrateIdLDAP(toAttribute string) *model.AppError {
func (a *App) MigrateIdLDAP(c *request.Context, toAttribute string) *model.AppError {
if ldapI := a.Ldap(); ldapI != nil {
if err := ldapI.MigrateIDAttribute(toAttribute); err != nil {
if err := ldapI.MigrateIDAttribute(c, toAttribute); err != nil {
switch err := err.(type) {
case *model.AppError:
return err