From fa3dd6a84bb51e8a5c3d3183bdb692386bb77c5a Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 27 Jul 2017 19:22:23 -0400 Subject: If login is using mobile respond with JSON object (#7030) --- api/user.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'api') diff --git a/api/user.go b/api/user.go index 0b2fbfba8..bb63cc7e2 100644 --- a/api/user.go +++ b/api/user.go @@ -1202,9 +1202,15 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) { relayProps = model.MapFromJson(strings.NewReader(stateStr)) } + action := relayProps["action"] if user, err := samlInterface.DoLogin(encodedXML, relayProps); err != nil { - c.Err = err - c.Err.StatusCode = http.StatusFound + if action == model.OAUTH_ACTION_MOBILE { + err.Translate(c.T) + w.Write([]byte(err.ToJson())) + } else { + c.Err = err + c.Err.StatusCode = http.StatusFound + } return } else { if err := app.CheckUserAdditionalAuthenticationCriteria(user, ""); err != nil { @@ -1212,7 +1218,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) { c.Err.StatusCode = http.StatusFound return } - action := relayProps["action"] + switch action { case model.OAUTH_ACTION_SIGNUP: teamId := relayProps["team_id"] @@ -1243,8 +1249,8 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) { return } - if action == "mobile" { - w.Write([]byte("")) + if action == model.OAUTH_ACTION_MOBILE { + ReturnStatusOK(w) } else { http.Redirect(w, r, app.GetProtocol(r)+"://"+r.Host, http.StatusFound) } -- cgit v1.2.3-1-g7c22