fix(login): rename email field to login (#499)

Co-authored-by: ayn2op <ayn2op@mac.local>
This commit is contained in:
Ayyan 2025-02-17 13:28:30 -05:00 • committed by GitHub
parent f937d1a431
commit 071def74f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,9 +3,11 @@ package login
import (
"errors"
"log/slog"
"net/http"
"github.com/ayn2op/discordo/internal/consts"
"github.com/diamondburned/arikawa/v3/api"
"github.com/diamondburned/arikawa/v3/utils/httputil"
"github.com/rivo/tview"
"github.com/zalando/go-keyring"
)
@ -49,8 +51,16 @@ func (self *Form) login() {
// Spoof the user agent of a web browser.
client.UserAgent = consts.UserAgent
// Attempt to login using the email and password.
resp, err := client.Login(email, password)
body := httputil.WithJSONBody(struct {
Email string `json:"login"`
Password string `json:"password"`
}{email, password})
var (
resp *api.LoginResponse
err error
)
err = client.RequestJSON(&resp, http.MethodPost, api.EndpointLogin, body)
if err != nil {
self.onError(err)
return