Skip to content
Snippets Groups Projects
Commit 47e702ab authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Do login if the provided token is invalid

parent 14749551
No related branches found
No related tags found
No related merge requests found
...@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment