Remove printing from client register code
This commit is contained in:
parent
75732476be
commit
b1e4a0cf72
2 changed files with 8 additions and 9 deletions
|
@ -3,7 +3,6 @@ package client
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -11,7 +10,7 @@ import (
|
||||||
"crispbyte.dev/sig-auth/server"
|
"crispbyte.dev/sig-auth/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
func RegisterKey(baseUrl *url.URL, key string, userId string) (string, error) {
|
||||||
request := server.RegisterRequest{
|
request := server.RegisterRequest{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Key: key,
|
Key: key,
|
||||||
|
@ -27,7 +26,7 @@ func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
||||||
bytes.NewBuffer(json_data))
|
bytes.NewBuffer(json_data))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
@ -35,12 +34,10 @@ func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
||||||
out, err := io.ReadAll(resp.Body)
|
out, err := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(resp.StatusCode)
|
keyId := string(out[:])
|
||||||
fmt.Println(resp.Header)
|
|
||||||
fmt.Println(string(out[:]))
|
|
||||||
|
|
||||||
return nil
|
return keyId, nil
|
||||||
}
|
}
|
||||||
|
|
4
main.go
4
main.go
|
@ -108,11 +108,13 @@ func registerKey(baseUrl *url.URL, keyFile string, userId string) {
|
||||||
|
|
||||||
keyText := string(keyBytes)
|
keyText := string(keyBytes)
|
||||||
|
|
||||||
err = client.RegisterKey(baseUrl, keyText, userId)
|
keyId, err := client.RegisterKey(baseUrl, keyText, userId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Registered key id: %s\n", keyId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServer(simulateCaddy bool, useTempDb bool, dbPath string) {
|
func runServer(simulateCaddy bool, useTempDb bool, dbPath string) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue