diff --git a/client/security.coffee b/client/security.coffee index a312041..502f55c 100644 --- a/client/security.coffee +++ b/client/security.coffee @@ -114,38 +114,46 @@ setup = (user) -> lastCookie = currentCookie , 100 - wiki.getScript '/security/winchan.js' - if (!$("link[href='/security/style.css']").length) - $('').appendTo("head") - myInit = { - method: 'GET' - cache: 'no-cache' - mode: 'same-origin' - } - fetch '/auth/client-settings.json', myInit - .then (response) -> - if response.ok - response.json().then (json) -> - settings = json - if settings.wikiHost - dialogHost = settings.wikiHost - else - dialogHost = window.location.hostname - settings.cookieDomain = dialogHost - if settings.useHttps - dialogProtocol = 'https:' - else - dialogProtocol = window.location.protocol - if window.location.port - dialogHost = dialogHost + ':' + window.location.port - if settings.usingPersona - settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/personaLogin' - else - settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog' - settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html' + wiki.getScript '/security/modernizr-custom.js', () -> + console.log 'modernizr loaded' + unless Modernizr.promises + require('es6-promise').polyfill() - update_footer ownerName, isAuthenticated - else - console.log 'Unable to fetch client settings: ', response + unless Modernizr.fetch + require('whatwg-fetch') + + wiki.getScript '/security/winchan.js' + if (!$("link[href='/security/style.css']").length) + $('').appendTo("head") + myInit = { + method: 'GET' + cache: 'no-cache' + mode: 'same-origin' + } + fetch '/auth/client-settings.json', myInit + .then (response) -> + if response.ok + response.json().then (json) -> + settings = json + if settings.wikiHost + dialogHost = settings.wikiHost + else + dialogHost = window.location.hostname + settings.cookieDomain = dialogHost + if settings.useHttps + dialogProtocol = 'https:' + else + dialogProtocol = window.location.protocol + if window.location.port + dialogHost = dialogHost + ':' + window.location.port + if settings.usingPersona + settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/personaLogin' + else + settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog' + settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html' + + update_footer ownerName, isAuthenticated + else + console.log 'Unable to fetch client settings: ', response window.plugins.security = {setup, claim_wiki, update_footer} diff --git a/package.json b/package.json index b032b05..8eda2f2 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,15 @@ "license": "MIT", "dependencies": { "coffee-script": "1.10", + "es6-promise": "^3.2.1", "lodash": "^4.13.1", "passport": "^0.3.2", "passport-github": "^1.1.0", "passport-google-oauth20": "^1.0.0", "passport-twitter": "^1.0.4", "persona-pass": "^0.2.1", - "qs": "^6.2.0" + "qs": "^6.2.0", + "whatwg-fetch": "^1.0.0" }, "devDependencies": { "coffeeify": "*",