MCPcopy Index your code
hub / github.com/rilldata/rill / logoutHandler

Method logoutHandler

cli/pkg/local/server.go:898–923  ·  view source on GitHub ↗

logoutHandler logs out the user and unsets the token stored

()

Source from the content-addressed store, hash-verified

896
897// logoutHandler logs out the user and unsets the token stored
898func (s *Server) logoutHandler() http.Handler {
899 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
900 // Logout the CLI
901 err := auth.Logout(r.Context(), s.app.ch)
902 if err != nil {
903 http.Error(w, fmt.Sprintf("failed to logout: %s", err), http.StatusInternalServerError)
904 return
905 }
906
907 // Get URL for cloud auth.
908 authURL := s.app.ch.AdminURL()
909
910 // Logout on cloud as well
911 var qry map[string]string
912 if r.URL.Query().Get("redirect") != "" {
913 qry = map[string]string{"redirect": r.URL.Query().Get("redirect")}
914 }
915 logoutURL, err := urlutil.WithQuery(urlutil.MustJoinURL(authURL, "auth", "logout"), qry)
916 if err != nil {
917 http.Error(w, fmt.Sprintf("failed to create logout URL: %s", err), http.StatusInternalServerError)
918 return
919 }
920
921 http.Redirect(w, r, logoutURL, http.StatusFound)
922 })
923}
924
925// trackingHandler proxies events to intake.rilldata.io.
926func (s *Server) trackingHandler() http.Handler {

Callers 1

RegisterHandlersMethod · 0.95

Calls 8

LogoutFunction · 0.92
WithQueryFunction · 0.92
MustJoinURLFunction · 0.92
AdminURLMethod · 0.80
ContextMethod · 0.65
GetMethod · 0.65
QueryMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected