This commit is contained in:
Till Faelligen 2022-05-25 08:49:34 +02:00
parent 87847532ee
commit 57035e4b4f

View file

@ -23,7 +23,6 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"github.com/tidwall/gjson"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -32,11 +31,14 @@ import (
"strings" "strings"
"time" "time"
"github.com/tidwall/gjson"
"github.com/sirupsen/logrus"
"golang.org/x/term"
"github.com/matrix-org/dendrite/setup" "github.com/matrix-org/dendrite/setup"
"github.com/matrix-org/dendrite/setup/base" "github.com/matrix-org/dendrite/setup/base"
"github.com/matrix-org/dendrite/userapi/storage" "github.com/matrix-org/dendrite/userapi/storage"
"github.com/sirupsen/logrus"
"golang.org/x/term"
) )
const usage = `Usage: %s const usage = `Usage: %s
@ -168,7 +170,7 @@ func sharedSecretRegister(sharedSecret, serverURL, localpart, password string, a
if err != nil { if err != nil {
return "", fmt.Errorf("failed to read response body: %w", err) return "", fmt.Errorf("failed to read response body: %w", err)
} }
defer nonceResp.Body.Close() defer nonceResp.Body.Close() // nolint: errcheck
nonce := gjson.GetBytes(body, "nonce").Str nonce := gjson.GetBytes(body, "nonce").Str
@ -201,7 +203,7 @@ func sharedSecretRegister(sharedSecret, serverURL, localpart, password string, a
if err != nil { if err != nil {
return "", fmt.Errorf("unable to create account: %w", err) return "", fmt.Errorf("unable to create account: %w", err)
} }
defer regResp.Body.Close() defer regResp.Body.Close() // nolint: errcheck
if regResp.StatusCode < 200 || regResp.StatusCode >= 300 { if regResp.StatusCode < 200 || regResp.StatusCode >= 300 {
body, _ = ioutil.ReadAll(regResp.Body) body, _ = ioutil.ReadAll(regResp.Body)
return "", fmt.Errorf(gjson.GetBytes(body, "error").Str) return "", fmt.Errorf(gjson.GetBytes(body, "error").Str)