Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cashier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kevin Lyda
cashier
Commits
47e702ab
Commit
47e702ab
authored
May 18, 2016
by
Niall Sheridan
Browse files
Options
Downloads
Patches
Plain Diff
Do login if the provided token is invalid
parent
14749551
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/main.go
+1
-4
1 addition, 4 deletions
server/main.go
with
1 addition
and
4 deletions
server/main.go
+
1
−
4
View file @
47e702ab
...
@@ -152,13 +152,10 @@ func callbackHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int
...
@@ -152,13 +152,10 @@ func callbackHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int
// rootHandler starts the auth process. If the client is authenticated it renders the token to the user.
// rootHandler starts the auth process. If the client is authenticated it renders the token to the user.
func
rootHandler
(
a
*
appContext
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
func
rootHandler
(
a
*
appContext
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
tok
:=
a
.
getAuthCookie
(
r
)
tok
:=
a
.
getAuthCookie
(
r
)
if
!
tok
.
Valid
()
{
if
!
tok
.
Valid
()
||
!
a
.
authprovider
.
Valid
(
tok
)
{
http
.
Redirect
(
w
,
r
,
"/auth/login"
,
http
.
StatusSeeOther
)
http
.
Redirect
(
w
,
r
,
"/auth/login"
,
http
.
StatusSeeOther
)
return
http
.
StatusSeeOther
,
nil
return
http
.
StatusSeeOther
,
nil
}
}
if
!
a
.
authprovider
.
Valid
(
tok
)
{
return
http
.
StatusUnauthorized
,
errors
.
New
(
http
.
StatusText
(
http
.
StatusUnauthorized
))
}
j
:=
jwt
.
New
(
jwt
.
SigningMethodHS256
)
j
:=
jwt
.
New
(
jwt
.
SigningMethodHS256
)
j
.
Claims
[
"token"
]
=
tok
.
AccessToken
j
.
Claims
[
"token"
]
=
tok
.
AccessToken
j
.
Claims
[
"exp"
]
=
tok
.
Expiry
.
Unix
()
j
.
Claims
[
"exp"
]
=
tok
.
Expiry
.
Unix
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment