Merge pull request #37 from fedwiki/paul90/login2view
Updating login to view
This commit is contained in:
commit
ebcfe9cc42
|
@ -31,10 +31,13 @@ claim_wiki = () ->
|
||||||
.then (response) ->
|
.then (response) ->
|
||||||
if response.ok
|
if response.ok
|
||||||
response.json().then (json) ->
|
response.json().then (json) ->
|
||||||
ownerName = json.ownerName
|
if wiki.lineup.bestTitle() is 'Login Required'
|
||||||
window.isClaimed = true
|
location.reload()
|
||||||
window.isOwner = true
|
else
|
||||||
update_footer ownerName, true
|
ownerName = json.ownerName
|
||||||
|
window.isClaimed = true
|
||||||
|
window.isOwner = true
|
||||||
|
update_footer ownerName, true
|
||||||
else
|
else
|
||||||
console.log 'Attempt to claim site failed', response
|
console.log 'Attempt to claim site failed', response
|
||||||
|
|
||||||
|
@ -103,7 +106,10 @@ update_footer = (ownerName, isAuthenticated) ->
|
||||||
if !isClaimed
|
if !isClaimed
|
||||||
claim_wiki()
|
claim_wiki()
|
||||||
else
|
else
|
||||||
update_footer ownerName, true)
|
if wiki.lineup.bestTitle() is 'Login Required'
|
||||||
|
location.reload()
|
||||||
|
else
|
||||||
|
update_footer ownerName, true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,8 +171,6 @@ setup = (user) ->
|
||||||
settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog'
|
settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog'
|
||||||
settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html'
|
settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html'
|
||||||
settings.dialogAddAltURL = dialogProtocol + '//' + dialogHost + '/auth/addAuthDialog'
|
settings.dialogAddAltURL = dialogProtocol + '//' + dialogHost + '/auth/addAuthDialog'
|
||||||
|
|
||||||
|
|
||||||
update_footer ownerName, isAuthenticated
|
update_footer ownerName, isAuthenticated
|
||||||
else
|
else
|
||||||
console.log 'Unable to fetch client settings: ', response
|
console.log 'Unable to fetch client settings: ', response
|
||||||
|
|
|
@ -400,15 +400,17 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
false
|
false
|
||||||
|
|
||||||
app.all '*', (req, res, next) ->
|
app.all '*', (req, res, next) ->
|
||||||
# todo: think about assets??
|
# don't protect site flag,
|
||||||
|
return next() if req.url is '/favicon.png'
|
||||||
return next() unless /\.(json|html)$/.test req.url
|
return next() unless /\.(json|html)$/.test req.url
|
||||||
|
|
||||||
# prepare to examine remote server's forwarded session
|
# prepare to examine remote server's forwarded session
|
||||||
res.header 'Access-Control-Allow-Origin', req.get('Origin')||'*'
|
res.header 'Access-Control-Allow-Origin', req.get('Origin')||'*'
|
||||||
res.header 'Access-Control-Allow-Credentials', 'true'
|
res.header 'Access-Control-Allow-Credentials', 'true'
|
||||||
return next() if isAuthorized(req) || allowedToView(req)
|
# protect unclaimed by adding "add owner isnt ''" - maybe via parameter
|
||||||
|
return next() if isAuthorized(req) or allowedToView(req)
|
||||||
return res.redirect("/view/#{m[1]}") if m = req.url.match /\/(.*)\.html/
|
return res.redirect("/view/#{m[1]}") if m = req.url.match /\/(.*)\.html/
|
||||||
return res.json([]) if req.url == '/system/sitemap.json'
|
return res.json(['Login Required']) if req.url == '/system/sitemap.json'
|
||||||
|
|
||||||
# not happy, explain why these pages can't be viewed
|
# not happy, explain why these pages can't be viewed
|
||||||
problem = "This is a restricted wiki requires users to login to view pages. You do not have to be the site owner but you do need to login with a participating email address."
|
problem = "This is a restricted wiki requires users to login to view pages. You do not have to be the site owner but you do need to login with a participating email address."
|
||||||
|
|
Loading…
Reference in New Issue