Skip to content

Commit

Permalink
fix login
Browse files Browse the repository at this point in the history
  • Loading branch information
platinummonkey committed Jan 10, 2025
1 parent 817bf24 commit 6012bfe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion unifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,18 @@ func (u *Unifi) verifyPeerCertificate(certs [][]byte, _ [][]*x509.Certificate) e

// Login is a helper method. It can be called to grab a new authentication cookie.
func (u *Unifi) Login() error {
loginPath := APIStatusPath
params := ""

if u.Config.APIKey == "" {
params = fmt.Sprintf(`{"username":"%s","password":"%s"}`, u.User, u.Pass)
loginPath = APILoginPath
}

start := time.Now()

// magic login.
req, err := u.UniReq(APILoginPath, fmt.Sprintf(`{"username":"%s","password":"%s"}`, u.User, u.Pass))
req, err := u.UniReq(loginPath, params)
if err != nil {
return err
}
Expand Down

0 comments on commit 6012bfe

Please sign in to comment.