Skip to content

Commit

Permalink
fix login bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thftgr committed Sep 10, 2024
1 parent 8869780 commit f340b0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion banchoCrawler/osuApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package banchoCrawler
import (
"bytes"
"encoding/base64"
"fmt"
"github.com/Nerinyan/Nerinyan-APIV2/config"
"github.com/goccy/go-json"
"github.com/pkg/errors"
"github.com/pterm/pterm"
"io/ioutil"
"mime/multipart"
Expand Down Expand Up @@ -64,7 +66,7 @@ func parseTokenExpiraton() (t int64) {
func tryLogin() (err error) {
spinner, _ := pterm.DefaultSpinner.Start("Trying Login Bancho...")
if err = login(true); err != nil {
spinner.Fail("fail refresh Bancho Token")
spinner.Fail("fail refresh Bancho Token: ", err)
if err = login(false); err != nil {
return
}
Expand Down Expand Up @@ -145,5 +147,8 @@ func login(refresh bool) (err error) {
return
}

if res.StatusCode != 200 {
return errors.New(fmt.Sprint(res.StatusCode, string(body)))
}
return json.Unmarshal(body, &config.Config.Osu.Token)
}

0 comments on commit f340b0c

Please sign in to comment.