MM-29123: Removed the hard coded gitlab.com in Terms of Service error (#20830)

Automatic Merge
Этот коммит содержится в:
kshitij katiyar
2022-09-08 15:34:00 +05:30
коммит произвёл GitHub
родитель 56bf9cec50
Коммит 5a718f3c63
2 изменённых файлов: 7 добавлений и 3 удалений

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

@@ -8,7 +8,6 @@ import (
"context"
b64 "encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -25,6 +24,7 @@ import (
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/store"
"github.com/mattermost/mattermost-server/v6/utils"
"github.com/pkg/errors"
)
const (
@@ -896,8 +896,12 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
mlog.Error("Error getting OAuth user", mlog.Int("response", resp.StatusCode), mlog.String("body_string", bodyString))
if service == model.ServiceGitlab && resp.StatusCode == http.StatusForbidden && strings.Contains(bodyString, "Terms of Service") {
url, err := url.Parse(*sso.UserAPIEndpoint)
if err != nil {
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(errors.Wrapf(err, "error parsing %s", *sso.UserAPIEndpoint))
}
// Return a nicer error when the user hasn't accepted GitLab's terms of service
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "oauth.gitlab.tos.error", nil, "", http.StatusBadRequest)
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "oauth.gitlab.tos.error", map[string]any{"URL": url.Hostname()}, "", http.StatusBadRequest)
}
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.response.app_error", nil, "response_body="+bodyString, http.StatusInternalServerError)

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

@@ -9273,7 +9273,7 @@
},
{
"id": "oauth.gitlab.tos.error",
"translation": "GitLab's Terms of Service have updated. Please go to gitlab.com to accept them and then try logging into Mattermost again."
"translation": "GitLab's Terms of Service have updated. Please go to {{.URL}} to accept them and then try logging into Mattermost again."
},
{
"id": "plugin.api.get_users_in_channel",