Skip to content

Commit 35db70b

Browse files
committed
feat(auth): include client identifier in email OTP request and set User-Agent header
1 parent c0a013c commit 35db70b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

internal/cli/client/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7+
"net/url"
78
)
89

910
// RequestEmailOTP sends an OTP to the given email address.
1011
// Corresponds to POST /v1/auth/login/email.
1112
func (c *Client) RequestEmailOTP(ctx context.Context, email string) error {
12-
resp, err := c.do(ctx, http.MethodPost, "/auth/login/email", nil, LoginEmailRequest{Email: email})
13+
q := url.Values{"client": {"cli"}}
14+
resp, err := c.do(ctx, http.MethodPost, "/auth/login/email", q, LoginEmailRequest{Email: email})
1315
if err != nil {
1416
return err
1517
}

internal/cli/client/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313

1414
"github.com/dployr-io/dployr/internal/cli/config"
15+
"github.com/dployr-io/dployr/pkg/version"
1516
)
1617

1718
// EnvToken is the environment variable checked before config for CI usage.
@@ -68,6 +69,7 @@ func (c *Client) do(ctx context.Context, method, path string, query url.Values,
6869
req.Header.Set("Content-Type", "application/json")
6970
}
7071
req.Header.Set("Accept", "application/json")
72+
req.Header.Set("User-Agent", "dployr-cli/"+version.Version)
7173

7274
c.setAuth(req)
7375

0 commit comments

Comments
 (0)