mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #699 from dotcloud/docker_login-fix
fix docker login when same username
This commit is contained in:
commit
58ce66e553
3 changed files with 12 additions and 7 deletions
8
api.go
8
api.go
|
@ -59,7 +59,7 @@ func getBoolParam(value string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
b, err := json.Marshal(srv.registry.GetAuthConfig())
|
b, err := json.Marshal(srv.registry.GetAuthConfig(false))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque
|
||||||
if err := json.NewDecoder(r.Body).Decode(config); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(config); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
authConfig := srv.registry.GetAuthConfig(true)
|
||||||
if config.Username == srv.registry.GetAuthConfig().Username {
|
if config.Username == authConfig.Username {
|
||||||
config.Password = srv.registry.GetAuthConfig().Password
|
config.Password = authConfig.Password
|
||||||
}
|
}
|
||||||
|
|
||||||
newAuthConfig := auth.NewAuthConfig(config.Username, config.Password, config.Email, srv.runtime.root)
|
newAuthConfig := auth.NewAuthConfig(config.Username, config.Password, config.Email, srv.runtime.root)
|
||||||
|
|
|
@ -1294,6 +1294,6 @@ func NewDockerCli(host string, port int) *DockerCli {
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockerCli struct {
|
type DockerCli struct {
|
||||||
host string
|
host string
|
||||||
port int
|
port int
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,9 +428,14 @@ func (r *Registry) ResetClient(authConfig *auth.AuthConfig) {
|
||||||
r.client.Jar = cookiejar.NewCookieJar()
|
r.client.Jar = cookiejar.NewCookieJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registry) GetAuthConfig() *auth.AuthConfig {
|
func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig {
|
||||||
|
password := ""
|
||||||
|
if withPasswd {
|
||||||
|
password = r.authConfig.Password
|
||||||
|
}
|
||||||
return &auth.AuthConfig{
|
return &auth.AuthConfig{
|
||||||
Username: r.authConfig.Username,
|
Username: r.authConfig.Username,
|
||||||
|
Password: password,
|
||||||
Email: r.authConfig.Email,
|
Email: r.authConfig.Email,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue