Skip to content

Commit

Permalink
Show reusable command in the case of auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Sep 2, 2024
1 parent 9d0d42e commit ada1974
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/api/json/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

package json

import "github.com/plesk/pleskapp/plesk/internal/locales"
import (
"github.com/plesk/pleskapp/plesk/internal/locales"
"net/url"
)

type jsonError struct {
Code int `json:"code"`
Expand Down Expand Up @@ -88,8 +91,14 @@ type authError struct {
}

func (e authError) Error() string {
serverUrl, err := url.Parse(e.server)
host := e.server
if err == nil {
host = serverUrl.Hostname()
}

if e.needReauth {
return locales.L.Get("api.errors.auth.failed.reauth", e.server)
return locales.L.Get("api.errors.auth.failed.reauth", host)
}
return locales.L.Get("api.errors.auth.wrong.pass", e.server)
return locales.L.Get("api.errors.auth.wrong.pass", host)
}

0 comments on commit ada1974

Please sign in to comment.