Files
backend/cmds/genToken.go
Yi-Ting Shih 1cf3a9ef0b
All checks were successful
Go test / run-go-vet (push) Successful in 6s
Go test / check-swagger-up-to-date (push) Successful in 10s
Go test / run-go-test (push) Successful in 36s
Go test / cleanup-go-test (push) Successful in 14s
Go test / release-image (push) Successful in 3m20s
Fix: cookie timeout
2025-12-12 02:09:46 +08:00

38 lines
686 B
Go

package cmds
import (
"fmt"
"net/http"
"github.com/go-resty/resty/v2"
"github.com/spf13/cobra"
)
type genLoginUrlPayload struct {
LoginUrl string `json:"loginUrl"`
}
type loginPayload struct {
Token string `json:"token"`
}
var genTokenCmd = &cobra.Command{
Use: "gen-token",
Run: func(cmd *cobra.Command, args []string) {
client := resty.New()
var payload genLoginUrlPayload
resp, err := client.R().
SetBody(`{"userId": "testuser1"}`).
SetAuthToken("poop").
SetResult(&payload).
Post("http://localhost:8080/auth/gen-login-url")
if err != nil || resp.StatusCode() != http.StatusOK {
panic(err)
}
fmt.Printf("url: %s\n", payload.LoginUrl)
},
}