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

View File

@ -5,24 +5,24 @@
"author": "Paul Rodwell <paul.rodwell@btinternet.com> (http://rodwell.me)",
"license": "MIT",
"dependencies": {
"coffee-script": "^1.11.1",
"es6-promise": "^4.0.5",
"lodash": "^4.17.2",
"coffee-script": "^1.12.4",
"es6-promise": "^4.1.0",
"lodash": "^4.17.4",
"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.3.0",
"whatwg-fetch": "^2.0.1"
"qs": "^6.4.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"coffeeify": "*",
"coffeeify": "^2.1.0",
"grunt": "^1.0.1",
"grunt-browserify": "~5",
"grunt-contrib-watch": "~1",
"grunt-git-authors": "^3.2.0",
"grunt-nsp": "*",
"grunt-retire": "^1.0.3"
"grunt-retire": "^1.0.7"
}
}