creack пре 12 година
родитељ
комит
e726bdcce2
2 измењених фајлова са 10 додато и 1 уклоњено
  1. 9 0
      auth/auth.go
  2. 1 1
      commands.go

+ 9 - 0
auth/auth.go

@@ -25,6 +25,15 @@ type AuthConfig struct {
 	rootPath string `json:-`
 }
 
+func NewAuthConfig(username, password, email, rootPath string) *AuthConfig {
+	return &AuthConfig{
+		Username: username,
+		Password: password,
+		Email:    email,
+		rootPath: rootPath,
+	}
+}
+
 // create a base64 encoded auth string to store in config
 func EncodeAuth(authConfig *AuthConfig) string {
 	authStr := authConfig.Username + ":" + authConfig.Password

+ 1 - 1
commands.go

@@ -94,7 +94,7 @@ func (srv *Server) CmdLogin(stdin io.ReadCloser, stdout io.Writer, args ...strin
 		password = srv.runtime.authConfig.Password
 		email = srv.runtime.authConfig.Email
 	}
-	newAuthConfig := &auth.AuthConfig{Username: username, Password: password, Email: email}
+	newAuthConfig := auth.NewAuthConfig(username, password, email, srv.runtime.root)
 	status, err := auth.Login(newAuthConfig)
 	if err != nil {
 		fmt.Fprintf(stdout, "Error : %s\n", err)