Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
c9610e0a
Commit
c9610e0a
authored
Dec 16, 2016
by
Kamil Trzcinski
Committed by
Z.J. van de Weg
Dec 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop failures
parent
e6637259
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+2
-2
lib/mattermost/session.rb
lib/mattermost/session.rb
+21
-15
No files found.
config/initializers/1_settings.rb
View file @
c9610e0a
lib/mattermost/session.rb
View file @
c9610e0a
...
@@ -54,7 +54,15 @@ module Mattermost
...
@@ -54,7 +54,15 @@ module Mattermost
end
end
def
params
def
params
Rack
::
Utils
.
parse_query
(
@oauth_uri
.
query
).
symbolize_keys
Rack
::
Utils
.
parse_query
(
oauth_uri
.
query
).
symbolize_keys
end
def
get
(
path
,
options
=
{})
self
.
class
.
get
(
path
,
options
.
merge
(
headers:
@headers
))
end
def
post
(
path
,
options
=
{})
self
.
class
.
post
(
path
,
options
.
merge
(
headers:
@headers
))
end
end
private
private
...
@@ -63,11 +71,12 @@ module Mattermost
...
@@ -63,11 +71,12 @@ module Mattermost
return
unless
oauth_uri
return
unless
oauth_uri
return
unless
token_uri
return
unless
token_uri
self
.
token
=
request_token
@
token
=
request_token
@headers
=
{
@headers
=
{
"Authorization"
:
"Bearer
#{
self
.
token
}
"
Authorization
:
"Bearer
#{
@
token
}
"
}
}
self
.
token
@token
end
end
def
destroy
def
destroy
...
@@ -75,35 +84,32 @@ module Mattermost
...
@@ -75,35 +84,32 @@ module Mattermost
end
end
def
oauth_uri
def
oauth_uri
return
@oauth_uri
if
defined?
(
@oauth_uri
)
@oauth_uri
=
nil
response
=
get
(
"/api/v3/oauth/gitlab/login"
,
follow_redirects:
false
)
response
=
get
(
"/api/v3/oauth/gitlab/login"
,
follow_redirects:
false
)
return
unless
300
<=
response
.
code
&&
response
.
code
<
400
return
unless
300
<=
response
.
code
&&
response
.
code
<
400
redirect_uri
=
response
.
headers
[
'location'
]
redirect_uri
=
response
.
headers
[
'location'
]
return
unless
redirect_uri
return
unless
redirect_uri
@oauth_uri
||
=
URI
.
parse
(
redirect_uri
)
@oauth_uri
=
URI
.
parse
(
redirect_uri
)
end
end
def
token_uri
def
token_uri
@token_uri
||=
@token_uri
||=
if
@
oauth_uri
if
oauth_uri
authorization
.
authorize
.
redirect_uri
if
pre_auth
.
authorizable?
authorization
.
authorize
.
redirect_uri
if
pre_auth
.
authorizable?
end
end
end
end
def
request_token
def
request_token
response
=
get
(
@token_uri
,
follow_redirects:
false
)
response
=
get
(
token_uri
,
follow_redirects:
false
)
if
200
<=
response
.
code
&&
response
.
code
<
400
if
200
<=
response
.
code
&&
response
.
code
<
400
response
.
headers
[
'token'
]
response
.
headers
[
'token'
]
end
end
end
end
def
get
(
path
,
options
=
{})
self
.
class
.
get
(
path
,
options
.
merge
(
headers:
@headers
))
end
def
post
(
path
,
options
=
{})
self
.
class
.
post
(
path
,
options
.
merge
(
headers:
@headers
))
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment