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
chatUrl: Settings.apis.chat.url
anonymous: anonymous
anonToken: req._anonToken
languages: Settings.languages
themes: THEME_LIST
maxDocLength: Settings.max_doc_length

View file

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

View file

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

View file

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