|
|
@@ -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
|