[MM-40735] Add MattermostAppID to OAuth app (#19214)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8d72cabee8
Коммит
7710a2fe37
@@ -18,17 +18,18 @@ const (
|
||||
)
|
||||
|
||||
type OAuthApp struct {
|
||||
Id string `json:"id"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"icon_url"`
|
||||
CallbackUrls StringArray `json:"callback_urls"`
|
||||
Homepage string `json:"homepage"`
|
||||
IsTrusted bool `json:"is_trusted"`
|
||||
Id string `json:"id"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"icon_url"`
|
||||
CallbackUrls StringArray `json:"callback_urls"`
|
||||
Homepage string `json:"homepage"`
|
||||
IsTrusted bool `json:"is_trusted"`
|
||||
MattermostAppID string `json:"mattermost_app_id"`
|
||||
}
|
||||
|
||||
// IsValid validates the app and returns an error if it isn't configured
|
||||
@@ -83,6 +84,10 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if len(a.MattermostAppID) > 32 {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.mattermost_app_id.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,9 @@ func TestOAuthAppIsValid(t *testing.T) {
|
||||
app.CallbackUrls = []string{"https://nowhere.com"}
|
||||
require.NotNil(t, app.IsValid())
|
||||
|
||||
app.MattermostAppID = "Some app ID"
|
||||
require.NotNil(t, app.IsValid())
|
||||
|
||||
app.Homepage = "https://nowhere.com"
|
||||
require.Nil(t, app.IsValid())
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ const (
|
||||
SessionPropUserAccessTokenId = "user_access_token_id"
|
||||
SessionPropIsBot = "is_bot"
|
||||
SessionPropIsBotValue = "true"
|
||||
SessionPropOAuthAppID = "oauth_app_id"
|
||||
SessionPropMattermostAppID = "mattermost_app_id"
|
||||
SessionTypeUserAccessToken = "UserAccessToken"
|
||||
SessionTypeCloudKey = "CloudKey"
|
||||
SessionTypeRemoteclusterToken = "RemoteClusterToken"
|
||||
|
||||
Ссылка в новой задаче
Block a user