fixed api calls

This commit is contained in:
ston1th 2022-07-10 01:51:33 +02:00
commit 69df101cb8
2 changed files with 28 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"html/template"
"net/http"
"strconv"
@ -209,6 +210,12 @@ func (c *Context) Form(name string) string {
return c.Request.PostFormValue(name)
}
func (c *Context) Query(name string) string {
// does nothing if called twice
c.Request.ParseForm()
return c.Request.Form.Get(name)
}
func (c *Context) Var(name string) (ret string) {
ret = mux.Vars(c.Request)[name]
return
@ -324,9 +331,9 @@ func (c *Context) ApproveLogin(user, challenge string) (rdr string, err error) {
}
func (c *Context) ApproveConsent(challenge string) (rdr string, err error) {
req := c.Srv.API.AdminApi.AcceptConsentRequest(context.Background())
req.AcceptConsentRequest(*client.NewAcceptConsentRequest())
req.ConsentChallenge(challenge)
req := c.Srv.API.AdminApi.AcceptConsentRequest(context.Background()).
AcceptConsentRequest(*client.NewAcceptConsentRequest()).
ConsentChallenge(challenge)
_, resp, err := req.Execute()
if err != nil {
return
@ -346,9 +353,9 @@ func (c *Context) ApproveConsent(challenge string) (rdr string, err error) {
}
func (c *Context) RejectConsent(challenge string) (rdr string, err error) {
req := c.Srv.API.AdminApi.RejectConsentRequest(context.Background())
req.RejectRequest(*client.NewRejectRequest())
req.ConsentChallenge(challenge)
req := c.Srv.API.AdminApi.RejectConsentRequest(context.Background()).
RejectRequest(*client.NewRejectRequest()).
ConsentChallenge(challenge)
_, resp, err := req.Execute()
if err != nil {
return
@ -368,10 +375,12 @@ func (c *Context) RejectConsent(challenge string) (rdr string, err error) {
}
func (c *Context) Consent(challenge string) (ci *consentInfo, err error) {
req := c.Srv.API.AdminApi.GetConsentRequest(context.Background())
req.ConsentChallenge(challenge)
fmt.Println(challenge)
req := c.Srv.API.AdminApi.GetConsentRequest(context.Background()).
ConsentChallenge(challenge)
_, resp, err := req.Execute()
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()