From 12080f04fb2121c1076a23cedc7e17e360da648d Mon Sep 17 00:00:00 2001 From: venomade Date: Mon, 16 Dec 2024 22:04:47 +0000 Subject: Improvements to README, DataDir, DEBUG and comments Expand README Remove Hardcoding of Data Directory Add DEBUG const Remove unnecesary comments --- authconf.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'authconf.go') diff --git a/authconf.go b/authconf.go index 2e9b81b..2a59392 100644 --- a/authconf.go +++ b/authconf.go @@ -22,16 +22,14 @@ func Auth(authFile string) UTRSimple { } func WriteAuth(authFile string) { - authToken, err := GetOAuth(clientID) + authToken, err := GetOAuth() if err != nil { panic(err) } uT := GetUserToken(authToken) - err = os.MkdirAll("/home/venomade/.local/share/lifesigns", 0755) - // TODO: unhardcode - + err = os.MkdirAll(dataDir, 0755) if err != nil { panic(err) } @@ -42,7 +40,7 @@ func WriteAuth(authFile string) { } defer file.Close() - confString := fmt.Sprintf("%s\n%s\n%s", uT.AccessToken, uT.ExpiresIn, uT.RefreshToken) + confString := fmt.Sprintf("%s\n%d\n%s", uT.AccessToken, uT.ExpiresIn, uT.RefreshToken) _, err = file.WriteString(confString) if err != nil { panic(err) @@ -57,10 +55,8 @@ func ReadAuth(authFile string) UTRSimple{ } defer file.Close() - // Create a slice to hold the lines of the file var lines []string - // Read all lines from the file into the slice scanner := bufio.NewScanner(file) for scanner.Scan() { lines = append(lines, scanner.Text()) @@ -68,8 +64,7 @@ func ReadAuth(authFile string) UTRSimple{ var utrs UTRSimple - // Process each line using the appropriate function - if len(lines) >= 2 { // Change to 3 + if len(lines) >= 3 { utrs.AccessToken = lines[0] exp, _ := strconv.Atoi(lines[1]) utrs.ExpiresIn = exp -- cgit 1.4.1-2-gfad0