Skip to content

Commit

Permalink
change ctoken name to token
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticrabbit committed Nov 13, 2021
1 parent 01e4b70 commit d7311e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var logoutCmd = &cobra.Command{
Long: `logout allows the user to delete the access token for accessing a Clickup workspace`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("deleted authentication token")
viper.Set("ctoken", "")
viper.Set("token", "")
viper.WriteConfigAs(config_file)
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func initConfig() {
}

func checkToken() {
if !viper.InConfig("ctoken") || viper.GetString("ctoken") == "" {
if !viper.InConfig("token") || viper.GetString("token") == "" {
token, err := internal.GetToken()
if err != nil {
log.Fatalln("auth failed")
}
viper.Set("cToken", token)
viper.Set("Token", token)
viper.WriteConfigAs(config_file)
}
}
4 changes: 1 addition & 3 deletions internal/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ func init() {

//Gets JSON data for any struct that implements Requester interface
func getJSON(apiPath string) []byte {
token := viper.GetString("ctoken")
req, _ := http.NewRequest(http.MethodGet, apiPath, nil)

req.Header.Add("Authorization", token)
req.Header.Add("Authorization", viper.GetString("token"))
req.Header.Add("Content-Type", "application/json")
resp, err := Client.Do(req)
if err != nil {
Expand Down

0 comments on commit d7311e2

Please sign in to comment.