diff --git a/client/security.coffee b/client/security.coffee index 07bb0cc..9ded753 100644 --- a/client/security.coffee +++ b/client/security.coffee @@ -51,7 +51,13 @@ update_footer = (ownerName, isAuthenticated) -> $('footer > #security').empty() if isAuthenticated - $('footer > #security').append "" + if isOwner + logoutTitle = "Sign-out" + logoutIconClass = 'fa fa-unlock fa-lg fa-fw' + else + logoutTitle = "Not Owner : Sign-out" + logoutIconClass = 'fa fa-lock fa-lg fa-fw notOwner' + $('footer > #security').append "" $('footer > #security > #logout').click (e) -> e.preventDefault() myInit = { @@ -167,7 +173,16 @@ setup = (user) -> switch document.cookie.match('(?:^|;)\\s?state=(.*?)(?:;|$)')[1] when 'loggedIn' then window.isAuthenticated = true when 'loggedOut' then window.isAuthenticated = false - update_footer ownerName, isAuthenticated + myInit = { + method: 'GET' + cache: 'no-cache' + mode: 'same-origin' + } + fetch '/auth/client-settings.json', myInit + .then (response) -> + response.json().then (json) -> + window.isOwner = json.isOwner + update_footer ownerName, isAuthenticated lastCookie = currentCookie , 100 diff --git a/client/style.css b/client/style.css index 66809b9..01daf55 100644 --- a/client/style.css +++ b/client/style.css @@ -8,6 +8,6 @@ color: floralwhite; } -#isOwner { - color: green; +.notOwner { + transform: rotate(20deg); } diff --git a/server/social.coffee b/server/social.coffee index 162acbd..b3bf2e0 100644 --- a/server/social.coffee +++ b/server/social.coffee @@ -133,6 +133,7 @@ module.exports = exports = (log, loga, argv) -> else try idProvider = _.head(_.keys(req.session.passport.user)) + console.log 'idProvider: ', idProvider switch idProvider when 'github', 'google', 'twitter' if _.isEqual(owner[idProvider].id, req.session.passport.user[idProvider].id) @@ -305,6 +306,10 @@ module.exports = exports = (log, loga, argv) -> } if wikiHost settings.wikiHost = wikiHost + if isAuthorized(req) and owner isnt '' + settings.isOwner = true + else + settings.isOwner = false res.json settings app.get '/auth/loginDialog', (req, res) ->