diff --git a/lib/qr.go b/lib/qr.go deleted file mode 100644 index 5e183a2..0000000 --- a/lib/qr.go +++ /dev/null @@ -1,16 +0,0 @@ -package lib - -import ( - "encoding/base64" - - "github.com/skip2/go-qrcode" -) - -func ToQR(s string) (string, error) { - png, err := qrcode.Encode(s, qrcode.Medium, 256) - if err != nil { - return "", err - } - qr := base64.StdEncoding.EncodeToString([]byte(png)) - return qr, nil -} diff --git a/server/router/handler/auth.go b/server/router/handler/auth.go index 79399d4..a00aa4a 100644 --- a/server/router/handler/auth.go +++ b/server/router/handler/auth.go @@ -5,7 +5,6 @@ import ( "net/http" "time" - "git.ekzyis.com/ekzyis/delphi.market/lib" "git.ekzyis.com/ekzyis/delphi.market/server/auth" "git.ekzyis.com/ekzyis/delphi.market/server/router/context" "git.ekzyis.com/ekzyis/delphi.market/server/router/pages" @@ -41,7 +40,6 @@ func LnAuth(sc context.Context, c echo.Context, action string) error { sessionId string // sessions expire in 30 days. TODO: refresh sessions expires = time.Now().Add(60 * 60 * 24 * 30 * time.Second) - qr string err error ) @@ -56,10 +54,6 @@ func LnAuth(sc context.Context, c echo.Context, action string) error { return err } - if qr, err = lib.ToQR(lnAuth.LNURL); err != nil { - return err - } - c.SetCookie(&http.Cookie{ Name: "session", HttpOnly: true, @@ -69,7 +63,7 @@ func LnAuth(sc context.Context, c echo.Context, action string) error { Expires: expires, }) - return pages.LnAuth(qr, lnAuth.LNURL, mapAction(action)).Render(context.RenderContext(sc, c), c.Response().Writer) + return pages.LnAuth(lnAuth.LNURL, mapAction(action)).Render(context.RenderContext(sc, c), c.Response().Writer) } func HandleLnAuthCallback(sc context.Context) echo.HandlerFunc { diff --git a/server/router/pages/components/qr.templ b/server/router/pages/components/qr.templ new file mode 100644 index 0000000..b0e2a1b --- /dev/null +++ b/server/router/pages/components/qr.templ @@ -0,0 +1,27 @@ +package components + +import ( + "encoding/base64" + "github.com/skip2/go-qrcode" +) + +templ Qr(value string, href string) { + if href != "" { + + + + } else { + + } +} + +func qrEncode(value string) string { + png, err := qrcode.Encode(value, qrcode.Medium, 256) + if err != nil { + return "" + } + return base64.StdEncoding.EncodeToString([]byte(png)) +} diff --git a/server/router/pages/lnAuth.templ b/server/router/pages/lnAuth.templ index 08df7a8..02d15cf 100644 --- a/server/router/pages/lnAuth.templ +++ b/server/router/pages/lnAuth.templ @@ -2,7 +2,7 @@ package pages import "git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components" -templ LnAuth(qr string, lnurl string, action string) { +templ LnAuth(lnurl string, action string) { @components.Head()
@@ -17,12 +17,7 @@ templ LnAuth(qr string, lnurl string, action string) { hx-select="#content" hx-push-url="true" > - - - + @components.Qr(lnurl, "lightning:"+lnurl) { lnurl }