Anon read-token: add an Authorization header to $http

This commit is contained in:
Shane Kilkelly 2017-09-29 15:54:55 +01:00
parent a66cb15f48
commit 34d4d1360f
4 changed files with 6 additions and 1 deletions

View file

@ -303,6 +303,7 @@ module.exports = ProjectController =
privilegeLevel: privilegeLevel privilegeLevel: privilegeLevel
chatUrl: Settings.apis.chat.url chatUrl: Settings.apis.chat.url
anonymous: anonymous anonymous: anonymous
anonToken: req._anonToken
languages: Settings.languages languages: Settings.languages
themes: THEME_LIST themes: THEME_LIST
maxDocLength: Settings.max_doc_length maxDocLength: Settings.max_doc_length

View file

@ -61,6 +61,7 @@ module.exports = TokenAccessController =
"error adding user to project with readAndWrite token" "error adding user to project with readAndWrite token"
return next(err) return next(err)
req.params.Project_id = project._id.toString() req.params.Project_id = project._id.toString()
req._anonToken = token
return ProjectController.loadEditor(req, res, next) return ProjectController.loadEditor(req, res, next)

View file

@ -118,6 +118,7 @@ block requirejs
window.user = data.user; window.user = data.user;
window.csrfToken = "!{csrfToken}"; window.csrfToken = "!{csrfToken}";
window.anonymous = #{anonymous}; window.anonymous = #{anonymous};
window.anonToken = "#{anonToken}";
window.maxDocLength = #{maxDocLength}; window.maxDocLength = #{maxDocLength};
window.trackChangesState = data.trackChangesState; window.trackChangesState = data.trackChangesState;
window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding}; window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding};

View file

@ -17,7 +17,9 @@ define [
"ErrorCatcher" "ErrorCatcher"
"localStorage" "localStorage"
"ngTagsInput" "ngTagsInput"
]).config ($qProvider, sixpackProvider)-> ]).config ($qProvider, sixpackProvider, $httpProvider)->
if window.anonToken
$httpProvider.defaults.headers.common['Authorization'] = window.anonToken
$qProvider.errorOnUnhandledRejections(false) $qProvider.errorOnUnhandledRejections(false)
sixpackProvider.setOptions({ sixpackProvider.setOptions({
debug: false debug: false