diff --git a/public/css/_tw-input.css b/public/css/_tw-input.css index 6d27a0c..6fed7c7 100644 --- a/public/css/_tw-input.css +++ b/public/css/_tw-input.css @@ -6,6 +6,10 @@ --background-color: #191d21; --color: #d3d3d3; --muted-color: #6c757d; + --lightning-color: #fada5e; + --nostr-color: #8d45dd; + --black: #000; + --white: #fff; } @layer base { @@ -48,6 +52,10 @@ aspect-ratio: 560/315; } + .text-muted { + color: var(--muted-color); + } + .figlet { display: flex; align-items: center; @@ -55,4 +63,30 @@ height: 144px; @apply my-3 } + + .login { + width: fit-content; + margin: 0 auto; + padding: 0.25em 1em; + border-radius: 5px; + font-weight: bold; + } + + .lightning { + background-color: var(--lightning-color); + color: var(--black); + } + + .lightning:hover { + filter: brightness(125%) drop-shadow(0 0 0.33rem var(--lightning-color)); + } + + .nostr { + background-color: var(--nostr-color); + color: var(--white); + } + + .nostr:hover { + filter: brightness(125%) drop-shadow(0 0 0.33rem var(--nostr-color)); + } } \ No newline at end of file diff --git a/server/router/handler/login.go b/server/router/handler/login.go index f1e755e..5518c27 100644 --- a/server/router/handler/login.go +++ b/server/router/handler/login.go @@ -3,44 +3,49 @@ package handler import ( "database/sql" "net/http" - "time" "git.ekzyis.com/ekzyis/delphi.market/db" - "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" "github.com/labstack/echo/v4" ) func HandleLogin(sc context.Context) echo.HandlerFunc { return func(c echo.Context) error { - var ( - lnAuth *auth.LNAuth - dbLnAuth db.LNAuth - err error - expires time.Time = time.Now().Add(60 * 60 * 24 * 365 * time.Second) - qr string - data map[string]any - ) - if lnAuth, err = auth.NewLNAuth(); err != nil { - return err - } - dbLnAuth = db.LNAuth{K1: lnAuth.K1, LNURL: lnAuth.LNURL} - if err = sc.Db.CreateLNAuth(&dbLnAuth); err != nil { - return err - } - c.SetCookie(&http.Cookie{Name: "session", HttpOnly: true, Path: "/", Value: dbLnAuth.SessionId, Secure: true, Expires: expires}) - if qr, err = lib.ToQR(lnAuth.LNURL); err != nil { - return err - } - data = map[string]any{ - "lnurl": lnAuth.LNURL, - "qr": qr, - } - return c.JSON(http.StatusOK, data) + return pages.Login().Render(context.RenderContext(sc, c), c.Response().Writer) } } +// func HandleLogin(sc context.Context) echo.HandlerFunc { +// return func(c echo.Context) error { +// var ( +// lnAuth *auth.LNAuth +// dbLnAuth db.LNAuth +// err error +// expires time.Time = time.Now().Add(60 * 60 * 24 * 365 * time.Second) +// qr string +// data map[string]any +// ) +// if lnAuth, err = auth.NewLNAuth(); err != nil { +// return err +// } +// dbLnAuth = db.LNAuth{K1: lnAuth.K1, LNURL: lnAuth.LNURL} +// if err = sc.Db.CreateLNAuth(&dbLnAuth); err != nil { +// return err +// } +// c.SetCookie(&http.Cookie{Name: "session", HttpOnly: true, Path: "/", Value: dbLnAuth.SessionId, Secure: true, Expires: expires}) +// if qr, err = lib.ToQR(lnAuth.LNURL); err != nil { +// return err +// } +// data = map[string]any{ +// "lnurl": lnAuth.LNURL, +// "qr": qr, +// } +// return c.JSON(http.StatusOK, data) +// } +// } + func HandleLoginCallback(sc context.Context) echo.HandlerFunc { return func(c echo.Context) error { var ( diff --git a/server/router/pages/login.templ b/server/router/pages/login.templ new file mode 100644 index 0000000..486e338 --- /dev/null +++ b/server/router/pages/login.templ @@ -0,0 +1,23 @@ +package pages + +import "git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components" + +templ Login() { + + @components.Head() + + @components.Header() +
+ @components.Figlet("random", "login") +
+
+ + +
+
+ new here? +
+ @components.Footer() + + +} diff --git a/server/router/router.go b/server/router/router.go index f750406..84fa948 100644 --- a/server/router/router.go +++ b/server/router/router.go @@ -15,4 +15,5 @@ func Init(e *echo.Echo, sc Context) { e.GET("/", handler.HandleIndex(sc)) e.GET("/about", handler.HandleAbout(sc)) + e.GET("/login", handler.HandleLogin(sc)) }