diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2018-08-20 17:18:27 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2018-08-20 17:18:27 +0100 |
commit | f906c9ba422eb720514721b559c01f840ca34a0c (patch) | |
tree | c7a8b0d4df7159b9b4ed959508b668c8f7e1c79d /server/web.go | |
parent | 87ae7c73ebe05f777e23087b1550d2cab42746ff (diff) |
Remove authprovider.Session
Diffstat (limited to 'server/web.go')
-rw-r--r-- | server/web.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/server/web.go b/server/web.go index 840ce1b..9114de1 100644 --- a/server/web.go +++ b/server/web.go @@ -28,7 +28,6 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/sessions" "github.com/nsheridan/cashier/lib" - "github.com/nsheridan/cashier/server/auth" "github.com/nsheridan/cashier/server/config" "github.com/nsheridan/cashier/server/templates" ) @@ -36,7 +35,6 @@ import ( // appContext contains local context - cookiestore, authsession etc. type appContext struct { cookiestore *sessions.CookieStore - authsession *auth.Session requireReason bool } @@ -172,8 +170,7 @@ func signHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, er func loginHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, error) { state := newState() a.setAuthStateCookie(w, r, state) - a.authsession = authprovider.StartSession(state) - http.Redirect(w, r, a.authsession.AuthURL, http.StatusFound) + http.Redirect(w, r, authprovider.StartSession(state), http.StatusFound) return http.StatusFound, nil } @@ -183,10 +180,11 @@ func callbackHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int return http.StatusUnauthorized, errors.New(http.StatusText(http.StatusUnauthorized)) } code := r.FormValue("code") - if err := a.authsession.Authorize(authprovider, code); err != nil { + token, err := authprovider.Exchange(code) + if err != nil { return http.StatusInternalServerError, err } - a.setAuthTokenCookie(w, r, a.authsession.Token) + a.setAuthTokenCookie(w, r, token) http.Redirect(w, r, a.getCurrentURL(r), http.StatusFound) return http.StatusFound, nil } |