diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-16 12:20:42 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-17 10:31:14 +0100 |
commit | e663725961de66ac838d0a5a85978656938e74f4 (patch) | |
tree | 1342f0caa56b37e02710b25f272969dfedfce902 /lib/mattermost | |
parent | 48ebfaa49146b8f6fcb24b063f22d553b2f20395 (diff) | |
download | gitlab-ce-e663725961de66ac838d0a5a85978656938e74f4.tar.gz |
Store mattermost_url in settings
Diffstat (limited to 'lib/mattermost')
-rw-r--r-- | lib/mattermost/session.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index 7d0290be5a1..a3715bed482 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -17,12 +17,11 @@ module Mattermost include Doorkeeper::Helpers::Controller include HTTParty - attr_accessor :current_resource_owner, :token + base_uri Settings.mattermost.host - def initialize(uri, current_user) - # Sets the base uri for HTTParty, so we can use paths - self.class.base_uri(uri) + attr_accessor :current_resource_owner, :token + def initialize(current_user) @current_resource_owner = current_user end @@ -30,7 +29,7 @@ module Mattermost raise NoSessionError unless create begin - yield + yield self ensure destroy end @@ -65,7 +64,9 @@ module Mattermost return unless token_uri self.token = request_token - self.class.headers("Cookie" => "MMAUTHTOKEN=#{self.token}") + @headers = { + "Authorization": "Bearer #{self.token}" + } self.token end @@ -98,11 +99,11 @@ module Mattermost end def get(path, options = {}) - self.class.get(path, options) + self.class.get(path, options.merge(headers: @headers)) end def post(path, options = {}) - self.class.post(path, options) + self.class.post(path, options.merge(headers: @headers)) end end end |