diff --git a/server/bindata.go b/server/bindata.go index dd0fe6a49612aae3051379399cc6c6c9e10213d5..f7ec29faa0facfd4e0befab1e54c277c7edea728 100644 --- a/server/bindata.go +++ b/server/bindata.go @@ -200,7 +200,7 @@ idlogout.get_services = function() { return JSON.parse($('#services').attr('data-services')); }; -idlogout.logout_service = function(service) { +idlogout.logout_service = function(idx, service) { var logout_url = service.url + 'sso_logout'; console.log('logging out of ' + service.name); $.ajax({ @@ -211,11 +211,11 @@ idlogout.logout_service = function(service) { withCredentials: true }, success: function() { - $('#status_'+service.idx).class('logout-status-ok').text('OK'); + $('#status_'+idx).class('logout-status-ok').text('OK'); console.log('successful logout for ' + service.name); }, error: function() { - $('#status_'+service.idx).class('logout-status-error').text('ERROR'); + $('#status_'+idx).class('logout-status-error').text('ERROR'); console.log('error logging out of ' + service.name); } }); @@ -224,7 +224,7 @@ idlogout.logout_service = function(service) { idlogout.logout = function() { var services = idlogout.get_services(); $.each(services, function(index, arg) { - idlogout.logout_service(arg); + idlogout.logout_service(index, arg); }); }; @@ -243,7 +243,7 @@ func staticJsLogoutJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/logout.js", size: 1019, mode: os.FileMode(436), modTime: time.Unix(1518961249, 0)} + info := bindataFileInfo{name: "static/js/logout.js", size: 1015, mode: os.FileMode(436), modTime: time.Unix(1518963191, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1276,7 +1276,7 @@ var _templatesLogoutHtml = []byte(`{{template "header" .}} {{end}} </ul> - <div id="#services" data-services="[{{range $i, $svc := .Services}}{{if gt $i 0}},{{end}}{%22idx%22:{{$i}},%22name%22:%22{{$svc.Name}}%22,%22url%22:%22{{$svc.URL}}%22}{{end}}]"></div> + <div id="services" data-services="{{.ServicesJSON}}"></div> </div> {{else}} @@ -1313,7 +1313,7 @@ func templatesLogoutHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/logout.html", size: 1505, mode: os.FileMode(436), modTime: time.Unix(1518961241, 0)} + info := bindataFileInfo{name: "templates/logout.html", size: 1381, mode: os.FileMode(436), modTime: time.Unix(1518963171, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1344,7 +1344,7 @@ var _templatesPageHtml = []byte(`{{define "header"}}<!DOCTYPE html> <script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script> {{end}} {{if .IncludeLogoutScripts}} - <script type="text/javascript" src="/static/js/logout.js" integrity="sha384-+V9VUvMMX5z37HxqZoSrTvQ2vHEH3OPksWy9gyQYfeWdzxtmpNR1r/z3+i0roLxS"></script> + <script type="text/javascript" src="/static/js/logout.js" integrity="sha384-swhUuZtRhByZOwc9Obn/dcrmcTXonO4xFuaIZKU3X8Ge/DSv3b+O4rL0+rjzRiRz"></script> {{end}} </body> </html> @@ -1361,7 +1361,7 @@ func templatesPageHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/page.html", size: 1686, mode: os.FileMode(436), modTime: time.Unix(1518961516, 0)} + info := bindataFileInfo{name: "templates/page.html", size: 1686, mode: os.FileMode(436), modTime: time.Unix(1518963201, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/server/http.go b/server/http.go index efd91d6c123d19608b5e4d0841ff5e5b89cc1ef4..1b669f36688f47e07ba3ad64586aec2bb8f9432f 100644 --- a/server/http.go +++ b/server/http.go @@ -5,6 +5,7 @@ package server import ( "encoding/gob" + "encoding/json" "fmt" "html/template" "io" @@ -234,8 +235,8 @@ func (h *Server) handleHomepage(w http.ResponseWriter, req *http.Request, sessio } type logoutServiceInfo struct { - URL string - Name string + URL string `json:"url"` + Name string `json:"name"` } func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session *authSession) { @@ -255,6 +256,7 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session if req.Method == "POST" { data["IsPOST"] = true data["IncludeLogoutScripts"] = true + data["ServicesJSON"], _ = json.Marshal(svcs) // Clear the local session. httpSession, _ := h.authSessionStore.Get(req, authSessionKey) diff --git a/server/static/js/logout.js b/server/static/js/logout.js index e8b48630bc12c8adcba094c464233f1390ea83c7..c516f35a40d22bf49b270ec9a7cc2cc64d0d6bf6 100644 --- a/server/static/js/logout.js +++ b/server/static/js/logout.js @@ -4,7 +4,7 @@ idlogout.get_services = function() { return JSON.parse($('#services').attr('data-services')); }; -idlogout.logout_service = function(service) { +idlogout.logout_service = function(idx, service) { var logout_url = service.url + 'sso_logout'; console.log('logging out of ' + service.name); $.ajax({ @@ -15,11 +15,11 @@ idlogout.logout_service = function(service) { withCredentials: true }, success: function() { - $('#status_'+service.idx).class('logout-status-ok').text('OK'); + $('#status_'+idx).class('logout-status-ok').text('OK'); console.log('successful logout for ' + service.name); }, error: function() { - $('#status_'+service.idx).class('logout-status-error').text('ERROR'); + $('#status_'+idx).class('logout-status-error').text('ERROR'); console.log('error logging out of ' + service.name); } }); @@ -28,7 +28,7 @@ idlogout.logout_service = function(service) { idlogout.logout = function() { var services = idlogout.get_services(); $.each(services, function(index, arg) { - idlogout.logout_service(arg); + idlogout.logout_service(index, arg); }); }; diff --git a/server/templates/logout.html b/server/templates/logout.html index 769b6b018d19df1393b534dad37e2a6fee0ed715..a6f12cc7a703a5368938348f28e667002045608f 100644 --- a/server/templates/logout.html +++ b/server/templates/logout.html @@ -32,7 +32,7 @@ {{end}} </ul> - <div id="#services" data-services="[{{range $i, $svc := .Services}}{{if gt $i 0}},{{end}}{%22idx%22:{{$i}},%22name%22:%22{{$svc.Name}}%22,%22url%22:%22{{$svc.URL}}%22}{{end}}]"></div> + <div id="services" data-services="{{.ServicesJSON}}"></div> </div> {{else}} diff --git a/server/templates/page.html b/server/templates/page.html index 103864b3683a22a54922a39d9300872a8a6ccdfb..9acab50485c7e656fb2b9f9ce06ad5c837b3c0d2 100644 --- a/server/templates/page.html +++ b/server/templates/page.html @@ -24,7 +24,7 @@ <script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script> {{end}} {{if .IncludeLogoutScripts}} - <script type="text/javascript" src="/static/js/logout.js" integrity="sha384-+V9VUvMMX5z37HxqZoSrTvQ2vHEH3OPksWy9gyQYfeWdzxtmpNR1r/z3+i0roLxS"></script> + <script type="text/javascript" src="/static/js/logout.js" integrity="sha384-swhUuZtRhByZOwc9Obn/dcrmcTXonO4xFuaIZKU3X8Ge/DSv3b+O4rL0+rjzRiRz"></script> {{end}} </body> </html>