mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
feat: implement passkey registration flow
This commit is contained in:
@@ -3,7 +3,6 @@ package database
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol"
|
||||
"github.com/labstack/echo/v4"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -17,13 +16,27 @@ var (
|
||||
ErrUserNotFound = echo.NewHTTPError(http.StatusNotFound, "User not found")
|
||||
)
|
||||
|
||||
// Define the credential structure matching our frontend data
|
||||
type Credential struct {
|
||||
ID string `json:"id"`
|
||||
RawID string `json:"rawId"`
|
||||
Type string `json:"type"`
|
||||
AuthenticatorAttachment string `json:"authenticatorAttachment"`
|
||||
Transports []string `json:"transports"`
|
||||
ClientExtensionResults map[string]interface{} `json:"clientExtensionResults"`
|
||||
Response struct {
|
||||
AttestationObject string `json:"attestationObject"`
|
||||
ClientDataJSON string `json:"clientDataJSON"`
|
||||
} `json:"response"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Name string `json:"name"`
|
||||
CID string `json:"cid"`
|
||||
Credentials []*protocol.CredentialDescriptor `json:"credentials"`
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Name string `json:"name"`
|
||||
CID string `json:"cid"`
|
||||
Credentials []*Credential `json:"credentials"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"github.com/onsonr/sonr/pkg/blocks/text"
|
||||
)
|
||||
|
||||
templ ProfileFormView(turnstileSiteKey string) {
|
||||
templ ProfileFormView(data forms.CreateProfileData) {
|
||||
@layout.Root("New Profile | Sonr.ID") {
|
||||
@layout.Container() {
|
||||
@text.Header("Create a Profile", "Enter some basic information about yourself.")
|
||||
@forms.CreateProfile("/register/start", "POST")
|
||||
@forms.CreateProfile("/register/start", "POST", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/onsonr/sonr/pkg/blocks/text"
|
||||
)
|
||||
|
||||
func ProfileFormView(turnstileSiteKey string) templ.Component {
|
||||
func ProfileFormView(data forms.CreateProfileData) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
@@ -67,7 +67,7 @@ func ProfileFormView(turnstileSiteKey string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = forms.CreateProfile("/register/start", "POST").Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = forms.CreateProfile("/register/start", "POST", data).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -34,13 +33,6 @@ func (s *HTTPContext) InitSession() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Println(sess.BrowserName)
|
||||
fmt.Println(sess.BrowserVersion)
|
||||
fmt.Println(sess.UserArchitecture)
|
||||
fmt.Println(sess.Platform)
|
||||
fmt.Println(sess.PlatformVersion)
|
||||
fmt.Println(sess.DeviceModel)
|
||||
|
||||
s.sess = &sess
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/pkg/gateway/config"
|
||||
"github.com/onsonr/sonr/pkg/gateway/internal/database"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Middleware creates a new session middleware
|
||||
func Middleware(db *gorm.DB) echo.MiddlewareFunc {
|
||||
func Middleware(db *gorm.DB, env config.Env) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
cc := NewHTTPContext(c, db)
|
||||
@@ -26,6 +27,7 @@ type HTTPContext struct {
|
||||
echo.Context
|
||||
db *gorm.DB
|
||||
sess *database.Session
|
||||
env config.Env
|
||||
}
|
||||
|
||||
// Get returns the HTTPContext from the echo context
|
||||
|
||||
Reference in New Issue
Block a user