Sfoglia il codice sorgente

Allow to change login

Guillaume J. Charmes 12 anni fa
parent
commit
bb85ce9aff
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 1 3
      api.go
  2. 5 0
      registry/registry.go

+ 1 - 3
api.go

@@ -72,9 +72,7 @@ func postAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[stri
 	if err != nil {
 		return err
 	} else {
-		// TODO: uncomment this
-		//		srv.runtime.graph.getHttpClient().Jar = cookiejar.NewCookieJar()
-		srv.runtime.authConfig = newAuthConfig
+		srv.registry.ResetClient(newAuthConfig)
 	}
 	if status != "" {
 		b, err := json.Marshal(&ApiAuth{Status: status})

+ 5 - 0
registry/registry.go

@@ -459,6 +459,11 @@ func (r *Registry) SearchRepositories(term string) (*SearchResults, error) {
 	return result, err
 }
 
+func (r *Registry) ResetClient(authConfig *auth.AuthConfig) {
+	r.authConfig = authConfig
+	r.client.Jar = cookiejar.NewCookieJar()
+}
+
 type SearchResults struct {
 	Query      string              `json:"query"`
 	NumResults int                 `json:"num_results"`