Handle auth error
This commit is contained in:
parent
9616eee62f
commit
86720ce988
1 changed files with 6 additions and 3 deletions
|
|
@ -105,8 +105,8 @@ func (b *BSky) GetPDS(handle string) string {
|
|||
func (b *BSky) Auth(authData []string) error {
|
||||
b.Bluesky.Cfg.Handle = authData[0]
|
||||
b.getPDS()
|
||||
auth, _ := loadAuth()
|
||||
if auth == nil || auth.AccessJWT == "" { // no auth session found
|
||||
auth, err := loadAuth()
|
||||
if err != nil { // no auth session found
|
||||
b.Bluesky.Cfg.AppPassword = authData[1]
|
||||
err := b.Bluesky.CreateSession(b.Bluesky.Cfg)
|
||||
if err != nil {
|
||||
|
|
@ -151,6 +151,9 @@ func loadAuth() (*BlueskyConfig, error) {
|
|||
}
|
||||
|
||||
var auth *BlueskyConfig
|
||||
json.Unmarshal(fBytes, &auth)
|
||||
err = json.Unmarshal(fBytes, &auth)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse auth file: %w", err)
|
||||
}
|
||||
return auth, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue