Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kevin Lyda
cashier
Commits
c18821f4
Commit
c18821f4
authored
Oct 22, 2018
by
Kevin Lyda
💬
Browse files
Handle reauths.
parent
3fda2211
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/server.go
View file @
c18821f4
...
...
@@ -252,12 +252,20 @@ func (a *app) setSessionVariable(w http.ResponseWriter, r *http.Request, key, va
func
(
a
*
app
)
authed
(
next
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
:=
a
.
getAuthToken
(
r
)
autoToken
:=
r
.
FormValue
(
"auto_token"
)
if
!
t
.
Valid
()
||
!
a
.
authprovider
.
Valid
(
t
)
{
a
.
setSessionVariable
(
w
,
r
,
"auto_token"
,
r
.
FormValue
(
"auto_token"
))
// This is the initial request - set auto_token regardless.
// This will handle cases where someone had an uto_token port
// and is not coming in without one.
a
.
setSessionVariable
(
w
,
r
,
"auto_token"
,
autoToken
)
a
.
setSessionVariable
(
w
,
r
,
"origin_url"
,
r
.
URL
.
EscapedPath
())
http
.
Redirect
(
w
,
r
,
"/auth/login"
,
http
.
StatusSeeOther
)
return
}
// We're already authed so set it to the new value.
if
autoToken
!=
""
{
a
.
setSessionVariable
(
w
,
r
,
"auto_token"
,
autoToken
)
}
next
.
ServeHTTP
(
w
,
r
)
})
}
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