prow/githuboauth/githuboauth.go
func (ga *Agent) HandleLogout(client OAuthClient) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		accessTokenSession, err := ga.gc.CookieStore.Get(r, tokenSession)
		if err != nil {
			ga.serverError(w, "get cookie", err)
			return
		}
		// Clear session
		accessTokenSession.Options.MaxAge = -1
		if err := accessTokenSession.Save(r, w); err != nil {
			ga.serverError(w, "Save invalidated session on log out", err)
			return
		}
		loginCookie, err := r.Cookie(loginSession)
		if err == nil {
			loginCookie.MaxAge = -1
			loginCookie.Expires = time.Now().Add(-time.Hour * 24)
			http.SetCookie(w, loginCookie)
		}
		http.Redirect(w, r, ga.gc.FinalRedirectURL, http.StatusFound)
	}
}
func (ga *Agent) HandleLogout(client OAuthClient) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		accessTokenSession, err := ga.gc.CookieStore.Get(r, tokenSession)
		if err != nil {
			ga.serverError(w, "get cookie", err)
			return
		}
		// Clear session
		accessTokenSession.Options.MaxAge = -1
		if err := accessTokenSession.Save(r, w); err != nil {
			ga.serverError(w, "Save invalidated session on log out", err)
			return
		}
		loginCookie, err := r.Cookie(loginSession)
		if err == nil {
			loginCookie.MaxAge = -1
			loginCookie.Expires = time.Now().Add(-time.Hour * 24)
			http.SetCookie(w, loginCookie)
		}
		http.Redirect(w, r, ga.gc.FinalRedirectURL, http.StatusFound)
	}
}
func ( ga * Agent ) HandleLogout ( client OAuthClient ) http . HandlerFunc { return func ( w http . ResponseWriter , r * http . Request ) { accessTokenSession , err := ga . gc . CookieStore . Get ( r , tokenSession ) if err != nil { ga . serverError ( w , " " , err ) return } // Clear session accessTokenSession . Options . MaxAge = - 1 if err := accessTokenSession . Save ( r , w ) ; err != nil { ga . serverError ( w , " " , err ) return } loginCookie , err := r . Cookie ( loginSession ) if err == nil { loginCookie . MaxAge = - 1 loginCookie . Expires = time . Now ( ) . Add ( - time . Hour * 24 ) http . SetCookie ( w , loginCookie ) } http . Redirect ( w , r , ga . gc . FinalRedirectURL , http . StatusFound ) } }
// HandleLogout handles GitHub logout request from front-end. It invalidates cookie sessions and
// redirect back to the front page.
HandleLogout handles GitHub logout request from front - end . It invalidates cookie sessions and redirect back to the front page .