Merge pull request #11 from fedwiki/paul90/update-state

update authentication state
This commit is contained in:
Ward Cunningham 2017-04-09 07:13:32 -07:00 committed by GitHub
commit c0fee618c5
2 changed files with 15 additions and 14 deletions

View File

@ -63,8 +63,7 @@ update_footer = (ownerName, isAuthenticated) ->
fetch '/logout', myInit fetch '/logout', myInit
.then (response) -> .then (response) ->
if response.ok if response.ok
isAuthenticated = false window.isAuthenticated = false
isOwner = false
user = '' user = ''
document.cookie = "state=loggedOut" + ";domain=." + settings.cookieDomain + "; path=/; max-age=60;" document.cookie = "state=loggedOut" + ";domain=." + settings.cookieDomain + "; path=/; max-age=60;"
update_footer ownerName, isAuthenticated update_footer ownerName, isAuthenticated
@ -138,10 +137,12 @@ update_footer = (ownerName, isAuthenticated) ->
}, (err, r) -> }, (err, r) ->
if err if err
console.log err console.log err
else if !isClaimed
claim_wiki()
else else
update_footer ownerName, true) window.isAuthenticated = true
if !isClaimed
claim_wiki()
else
update_footer ownerName, true)
@ -160,8 +161,8 @@ setup = (user) ->
unless document.cookie.match('(?:^|;)\\s?state=(.*?)(?:;|$)') is null unless document.cookie.match('(?:^|;)\\s?state=(.*?)(?:;|$)') is null
try try
switch document.cookie.match('(?:^|;)\\s?state=(.*?)(?:;|$)')[1] switch document.cookie.match('(?:^|;)\\s?state=(.*?)(?:;|$)')[1]
when 'loggedIn' then isAuthenticated = true when 'loggedIn' then window.isAuthenticated = true
when 'loggedOut' then isAuthenticated = false when 'loggedOut' then window.isAuthenticated = false
update_footer ownerName, isAuthenticated update_footer ownerName, isAuthenticated
lastCookie = currentCookie lastCookie = currentCookie
, 100 , 100

View File

@ -5,24 +5,24 @@
"author": "Paul Rodwell <paul.rodwell@btinternet.com> (http://rodwell.me)", "author": "Paul Rodwell <paul.rodwell@btinternet.com> (http://rodwell.me)",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"coffee-script": "^1.11.1", "coffee-script": "^1.12.4",
"es6-promise": "^4.0.5", "es6-promise": "^4.1.0",
"lodash": "^4.17.2", "lodash": "^4.17.4",
"passport": "^0.3.2", "passport": "^0.3.2",
"passport-github": "^1.1.0", "passport-github": "^1.1.0",
"passport-google-oauth20": "^1.0.0", "passport-google-oauth20": "^1.0.0",
"passport-twitter": "^1.0.4", "passport-twitter": "^1.0.4",
"persona-pass": "^0.2.1", "persona-pass": "^0.2.1",
"qs": "^6.3.0", "qs": "^6.4.0",
"whatwg-fetch": "^2.0.1" "whatwg-fetch": "^2.0.3"
}, },
"devDependencies": { "devDependencies": {
"coffeeify": "*", "coffeeify": "^2.1.0",
"grunt": "^1.0.1", "grunt": "^1.0.1",
"grunt-browserify": "~5", "grunt-browserify": "~5",
"grunt-contrib-watch": "~1", "grunt-contrib-watch": "~1",
"grunt-git-authors": "^3.2.0", "grunt-git-authors": "^3.2.0",
"grunt-nsp": "*", "grunt-nsp": "*",
"grunt-retire": "^1.0.3" "grunt-retire": "^1.0.7"
} }
} }