Add login page
This commit is contained in:
parent
fb26910e41
commit
94d1f6c1d8
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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 (
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package pages
|
||||
|
||||
import "git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components"
|
||||
|
||||
templ Login() {
|
||||
<html>
|
||||
@components.Head()
|
||||
<body class="container">
|
||||
@components.Header()
|
||||
<div class="flex flex-col text-center">
|
||||
@components.Figlet("random", "login")
|
||||
</div>
|
||||
<div class="flex flex-col mb-3 text-center">
|
||||
<button class="login lightning my-3">login with lightning</button>
|
||||
<button class="login nostr my-3">login with nostr</button>
|
||||
</div>
|
||||
<div class="flex flex-col mb-3 text-center">
|
||||
<small><a class="text-muted" href="/signup">new here?</a></small>
|
||||
</div>
|
||||
@components.Footer()
|
||||
</body>
|
||||
</html>
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue