summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2017-07-27 19:22:23 -0400
committerSaturnino Abril <saturnino.abril@gmail.com>2017-08-03 02:39:14 +0800
commitfa3dd6a84bb51e8a5c3d3183bdb692386bb77c5a (patch)
treeeea9c86827db6933d535fb9172f39c348f586e77 /api
parentb796960a2514a2eb5ae900436806f343dbddf50f (diff)
downloadchat-fa3dd6a84bb51e8a5c3d3183bdb692386bb77c5a.tar.gz
chat-fa3dd6a84bb51e8a5c3d3183bdb692386bb77c5a.tar.bz2
chat-fa3dd6a84bb51e8a5c3d3183bdb692386bb77c5a.zip
If login is using mobile respond with JSON object (#7030)
Diffstat (limited to 'api')
-rw-r--r--api/user.go16
1 files changed, 11 insertions, 5 deletions
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)
}