Skip to content

Commit

Permalink
login CRLF fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hhio618 committed Sep 13, 2018
1 parent 4523177 commit 9ae5d8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmd/auth.go
Expand Up @@ -33,15 +33,15 @@ func login(cmd *cobra.Command, args []string) {
req := &uvApi.LoginReq{Email: email, Password: password}
res, err := client.V1().Login(client.Context(), req)
if err != nil {
log.Fatalf("Could not Login: %v", err)
log.Fatalf("\r\nCould not Login: %v", err)
}

log.Printf("Login successful!")
log.Printf("\r\nLogin successful!")
viper.Set(config.KEY_TOKEN, res.Token)

// Save TOKEN to config file
if err = config.ResetConfigFile(); err != nil {
log.Fatalf("Could not Save ConfigFile: %v", err)
log.Fatalf("\r\nCould not Save ConfigFile: %v", err)
}
}

Expand Down
5 changes: 4 additions & 1 deletion config/config.go
Expand Up @@ -21,7 +21,7 @@ const (
)

var (
// Get config file Path from the flag.
//ConfigManualAddress Get config file Path from the flag.
ConfigManualAddress = ""

// Find home directory for definition of archive folder
Expand All @@ -44,6 +44,7 @@ func isJSON(in []byte) bool {

}

//ensureConfigFile Ensure that a valid config file exists
func ensureConfigFile(filename string) {
var err error
var f *os.File
Expand Down Expand Up @@ -76,6 +77,7 @@ func ensureConfigFile(filename string) {
}
}

//UpdateVarByConfigFile read config file into viper
func UpdateVarByConfigFile() {
// read config either from Flag --config or Path "$HOME/.uv/config.json"
var filename string
Expand All @@ -94,6 +96,7 @@ func UpdateVarByConfigFile() {
}
}

//ResetConfigFile wipes config file
func ResetConfigFile() (err error) {
return viper.WriteConfig()
}

0 comments on commit 9ae5d8f

Please sign in to comment.