diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-05-18 21:31:36 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-05-18 21:31:36 +0100 |
commit | 47e702ab1d0c1b92b76663ba027c7c20122efab7 (patch) | |
tree | b2325e46c5716c9c71261c2e21920985d690c311 | |
parent | 1474955143f29c61639df2a106287a36b9a93214 (diff) |
Do login if the provided token is invalid
-rw-r--r-- | server/main.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/server/main.go b/server/main.go index 4f1cbd6..786fc9f 100644 --- a/server/main.go +++ b/server/main.go @@ -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. func rootHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, error) { tok := a.getAuthCookie(r) - if !tok.Valid() { + if !tok.Valid() || !a.authprovider.Valid(tok) { http.Redirect(w, r, "/auth/login", http.StatusSeeOther) return http.StatusSeeOther, nil } - if !a.authprovider.Valid(tok) { - return http.StatusUnauthorized, errors.New(http.StatusText(http.StatusUnauthorized)) - } j := jwt.New(jwt.SigningMethodHS256) j.Claims["token"] = tok.AccessToken j.Claims["exp"] = tok.Expiry.Unix() |