Этот коммит содержится в:
Ben Schumacher
2021-07-12 20:05:36 +02:00
коммит произвёл Claudio Costa
родитель 953eebdef4
Коммит 97ccf0bdf6
472 изменённых файлов: 9126 добавлений и 9132 удалений

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

@@ -35,7 +35,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
action := r.URL.Query().Get("action")
isMobile := action == model.OAUTH_ACTION_MOBILE
isMobile := action == model.OAuthActionMobile
redirectURL := html.EscapeString(r.URL.Query().Get("redirect_to"))
relayProps := map[string]string{}
relayState := ""
@@ -43,7 +43,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
if action != "" {
relayProps["team_id"] = teamId
relayProps["action"] = action
if action == model.OAUTH_ACTION_EMAIL_TO_SSO {
if action == model.OAuthActionEmailToSSO {
relayProps["email"] = r.URL.Query().Get("email")
}
}
@@ -57,7 +57,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
relayProps["redirect_to"] = redirectURL
}
relayProps[model.USER_AUTH_SERVICE_IS_MOBILE] = strconv.FormatBool(isMobile)
relayProps[model.UserAuthServiceIsMobile] = strconv.FormatBool(isMobile)
if len(relayProps) > 0 {
relayState = b64.StdEncoding.EncodeToString([]byte(model.MapToJson(relayProps)))
@@ -103,7 +103,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
action := relayProps["action"]
auditRec.AddMeta("action", action)
isMobile := action == model.OAUTH_ACTION_MOBILE
isMobile := action == model.OAuthActionMobile
redirectURL := ""
hasRedirectURL := false
if val, ok := relayProps["redirect_to"]; ok {
@@ -136,7 +136,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
switch action {
case model.OAUTH_ACTION_SIGNUP:
case model.OAuthActionSignup:
if teamId := relayProps["team_id"]; teamId != "" {
if err = c.App.AddUserToTeamByTeamId(c.AppContext, teamId, user); err != nil {
c.LogErrorByCode(err)
@@ -144,7 +144,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
c.App.AddDirectChannels(teamId, user)
}
case model.OAUTH_ACTION_EMAIL_TO_SSO:
case model.OAuthActionEmailToSSO:
if err = c.App.RevokeAllSessions(user.Id); err != nil {
c.Err = err
return
@@ -154,7 +154,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAuditWithUserId(user.Id, "Revoked all sessions for user")
c.App.Srv().Go(func() {
if err := c.App.Srv().EmailService.SendSignInChangeEmail(user.Email, strings.Title(model.USER_AUTH_SERVICE_SAML)+" SSO", user.Locale, c.App.GetSiteURL()); err != nil {
if err := c.App.Srv().EmailService.SendSignInChangeEmail(user.Email, strings.Title(model.UserAuthServiceSaml)+" SSO", user.Locale, c.App.GetSiteURL()); err != nil {
c.LogErrorByCode(model.NewAppError("SendSignInChangeEmail", "api.user.send_sign_in_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError))
}
})
@@ -179,8 +179,8 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
if isMobile {
// Mobile clients with redirect url support
redirectURL = utils.AppendQueryParamsToURL(redirectURL, map[string]string{
model.SESSION_COOKIE_TOKEN: c.AppContext.Session().Token,
model.SESSION_COOKIE_CSRF: c.AppContext.Session().GetCSRF(),
model.SessionCookieToken: c.AppContext.Session().Token,
model.SessionCookieCsrf: c.AppContext.Session().GetCSRF(),
})
utils.RenderMobileAuthComplete(w, redirectURL)
} else {
@@ -192,9 +192,9 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
switch action {
// Mobile clients with web view implementation
case model.OAUTH_ACTION_MOBILE:
case model.OAuthActionMobile:
ReturnStatusOK(w)
case model.OAUTH_ACTION_EMAIL_TO_SSO:
case model.OAuthActionEmailToSSO:
http.Redirect(w, r, c.GetSiteURLHeader()+"/login?extra=signin_change", http.StatusFound)
default:
http.Redirect(w, r, c.GetSiteURLHeader(), http.StatusFound)