From 47e702ab1d0c1b92b76663ba027c7c20122efab7 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Wed, 18 May 2016 21:31:36 +0100 Subject: Do login if the provided token is invalid --- server/main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'server') 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() -- cgit v1.2.3