[MM-64896][MM-64898] Pass inviteid/tokenid to relay state/props for external auth when auto-joining a team (#33545) (#33666)

Automatic Merge
Этот коммит содержится в:
Mattermost Build
2025-08-13 13:04:00 +03:00
коммит произвёл GitHub
родитель ed9e2dbbce
Коммит 2d5cdc6e21
7 изменённых файлов: 129 добавлений и 106 удалений

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

@@ -31,11 +31,9 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
teamId, err := c.App.GetTeamIdFromQuery(c.AppContext, r.URL.Query())
if err != nil {
c.Err = err
return
}
tokenID := r.URL.Query().Get("t")
inviteId := r.URL.Query().Get("id")
action := r.URL.Query().Get("action")
isMobile := action == model.OAuthActionMobile
redirectURL := html.EscapeString(r.URL.Query().Get("redirect_to"))
@@ -43,7 +41,11 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
relayState := ""
if action != "" {
relayProps["team_id"] = teamId
if tokenID != "" {
relayProps["invite_token"] = tokenID
} else if inviteId != "" {
relayProps["invite_id"] = inviteId
}
relayProps["action"] = action
if action == model.OAuthActionEmailToSSO {
relayProps["email_token"] = r.URL.Query().Get("email_token")
@@ -149,14 +151,11 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
switch action {
case model.OAuthActionSignup:
if teamId := relayProps["team_id"]; teamId != "" {
if err = c.App.AddUserToTeamByTeamId(c.AppContext, teamId, user); err != nil {
c.LogErrorByCode(err)
break
}
if err = c.App.AddDirectChannels(c.AppContext, teamId, user); err != nil {
c.LogErrorByCode(err)
}
inviteToken := relayProps["invite_token"]
inviteId := relayProps["invite_id"]
if err = c.App.AddUserToTeamByInviteIfNeeded(c.AppContext, user, inviteToken, inviteId); err != nil {
c.LogErrorByCode(err)
break
}
case model.OAuthActionEmailToSSO:
if err = c.App.RevokeAllSessions(c.AppContext, user.Id); err != nil {