From 26cdbd5dbadec45e854fe67ccb39a2b2c9d040e7 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Tue, 1 Sep 2020 12:25:00 +0300 Subject: [PATCH] api4/user: fix-failing-ee-tests (#15372) Co-authored-by: Mattermod --- api4/user.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/api4/user.go b/api4/user.go index 3d3647b575..0aabc9ef51 100644 --- a/api4/user.go +++ b/api4/user.go @@ -2594,6 +2594,16 @@ func migrateAuthToLDAP(c *Context, w http.ResponseWriter, r *http.Request) { return } + if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP { + c.Err = model.NewAppError("api.migrateAuthToLDAP", "api.admin.ldap.not_available.app_error", nil, "", http.StatusNotImplemented) + return + } + + // Email auth in Mattermost system is represented by "" + if from == "email" { + from = "" + } + if migrate := c.App.AccountMigration(); migrate != nil { if err := migrate.MigrateToLdap(from, matchField, force, false); err != nil { c.Err = model.NewAppError("api.migrateAuthToLdap", "api.migrate_to_saml.error", nil, err.Error(), http.StatusInternalServerError) @@ -2643,6 +2653,16 @@ func migrateAuthToSaml(c *Context, w http.ResponseWriter, r *http.Request) { return } + if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.SAML { + c.Err = model.NewAppError("api.migrateAuthToSaml", "api.admin.saml.not_available.app_error", nil, "", http.StatusNotImplemented) + return + } + + // Email auth in Mattermost system is represented by "" + if from == "email" { + from = "" + } + if migrate := c.App.AccountMigration(); migrate != nil { if err := migrate.MigrateToSaml(from, usersMap, auto, false); err != nil { c.Err = model.NewAppError("api.migrateAuthToSaml", "api.migrate_to_saml.error", nil, err.Error(), http.StatusInternalServerError)