mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +00:00
feat: implement authentication register finish endpoint
This commit is contained in:
parent
2479bae12e
commit
7cbc9e0bb1
@ -6,18 +6,21 @@ import (
|
|||||||
"github.com/onsonr/sonr/pkg/nebula/global/styles"
|
"github.com/onsonr/sonr/pkg/nebula/global/styles"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RegisterModal returns the Register Modal.
|
||||||
templ RegisterModal(c echo.Context) {
|
templ RegisterModal(c echo.Context) {
|
||||||
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
||||||
@sections.RegisterStart()
|
@sections.RegisterStart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginModal returns the Login Modal.
|
||||||
templ LoginModal(c echo.Context) {
|
templ LoginModal(c echo.Context) {
|
||||||
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
||||||
@sections.LoginStart()
|
@sections.LoginStart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuthorizeModal returns the Authorize Modal.
|
||||||
templ AuthorizeModal(c echo.Context) {
|
templ AuthorizeModal(c echo.Context) {
|
||||||
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
@styles.OpenModal("Account Registration", "Enter your account information below to create your account.") {
|
||||||
@sections.AuthorizeStart()
|
@sections.AuthorizeStart()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
// │ DWN Routes - Authentication │
|
// │ DWN Routes - Authentication │
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
// ╰───────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
// CurrentViewRoute returns the current view route.
|
||||||
func CurrentViewRoute(c echo.Context) error {
|
func CurrentViewRoute(c echo.Context) error {
|
||||||
s, err := ctx.GetDWNContext(c)
|
s, err := ctx.GetDWNContext(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -24,14 +25,17 @@ func CurrentViewRoute(c echo.Context) error {
|
|||||||
// │ Hway Routes - Authentication │
|
// │ Hway Routes - Authentication │
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
// ╰───────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
// AuthorizeModalRoute returns the Authorize Modal route.
|
||||||
func AuthorizeModalRoute(c echo.Context) error {
|
func AuthorizeModalRoute(c echo.Context) error {
|
||||||
return ctx.RenderTempl(c, AuthorizeModal(c))
|
return ctx.RenderTempl(c, AuthorizeModal(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginModalRoute returns the Login Modal route.
|
||||||
func LoginModalRoute(c echo.Context) error {
|
func LoginModalRoute(c echo.Context) error {
|
||||||
return ctx.RenderTempl(c, LoginModal(c))
|
return ctx.RenderTempl(c, LoginModal(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterModalRoute returns the Register Modal route.
|
||||||
func RegisterModalRoute(c echo.Context) error {
|
func RegisterModalRoute(c echo.Context) error {
|
||||||
return ctx.RenderTempl(c, RegisterModal(c))
|
return ctx.RenderTempl(c, RegisterModal(c))
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,22 @@ package authentication
|
|||||||
|
|
||||||
import echo "github.com/labstack/echo/v4"
|
import echo "github.com/labstack/echo/v4"
|
||||||
|
|
||||||
|
// CurrentView checks if the user is logged in.
|
||||||
templ CurrentView(c echo.Context) {
|
templ CurrentView(c echo.Context) {
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">Current Account</h3>
|
<h3 class="card-title">Current Account</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<a href="/logout">Logout</a>
|
<a href="/logout">Logout</a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,14 +7,20 @@ import (
|
|||||||
"github.com/onsonr/sonr/internal/orm"
|
"github.com/onsonr/sonr/internal/orm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type authAPI struct{}
|
||||||
|
|
||||||
|
var Auth = new(authAPI)
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
// ╭───────────────────────────────────────────────────────────╮
|
||||||
// │ Login Handlers │
|
// │ Login Handlers │
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
// ╰───────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
// LoginSubjectCheck handles the login subject check.
|
||||||
func (a *authAPI) LoginSubjectCheck(e echo.Context) error {
|
func (a *authAPI) LoginSubjectCheck(e echo.Context) error {
|
||||||
return e.JSON(200, "HandleCredentialAssertion")
|
return e.JSON(200, "HandleCredentialAssertion")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginSubjectStart handles the login subject start.
|
||||||
func (a *authAPI) LoginSubjectStart(e echo.Context) error {
|
func (a *authAPI) LoginSubjectStart(e echo.Context) error {
|
||||||
opts := &protocol.PublicKeyCredentialRequestOptions{
|
opts := &protocol.PublicKeyCredentialRequestOptions{
|
||||||
UserVerification: "preferred",
|
UserVerification: "preferred",
|
||||||
@ -23,6 +29,7 @@ func (a *authAPI) LoginSubjectStart(e echo.Context) error {
|
|||||||
return e.JSON(200, opts)
|
return e.JSON(200, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginSubjectFinish handles the login subject finish.
|
||||||
func (a *authAPI) LoginSubjectFinish(e echo.Context) error {
|
func (a *authAPI) LoginSubjectFinish(e echo.Context) error {
|
||||||
var crr protocol.CredentialAssertionResponse
|
var crr protocol.CredentialAssertionResponse
|
||||||
if err := e.Bind(&crr); err != nil {
|
if err := e.Bind(&crr); err != nil {
|
||||||
@ -35,11 +42,13 @@ func (a *authAPI) LoginSubjectFinish(e echo.Context) error {
|
|||||||
// │ Register Handlers │
|
// │ Register Handlers │
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
// ╰───────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
// RegisterSubjectCheck handles the register subject check.
|
||||||
func (a *authAPI) RegisterSubjectCheck(e echo.Context) error {
|
func (a *authAPI) RegisterSubjectCheck(e echo.Context) error {
|
||||||
subject := e.FormValue("subject")
|
subject := e.FormValue("subject")
|
||||||
return e.JSON(200, subject)
|
return e.JSON(200, subject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterSubjectStart handles the register subject start.
|
||||||
func (a *authAPI) RegisterSubjectStart(e echo.Context) error {
|
func (a *authAPI) RegisterSubjectStart(e echo.Context) error {
|
||||||
// Get subject and address
|
// Get subject and address
|
||||||
subject := e.FormValue("subject")
|
subject := e.FormValue("subject")
|
||||||
@ -53,6 +62,7 @@ func (a *authAPI) RegisterSubjectStart(e echo.Context) error {
|
|||||||
return e.JSON(201, orm.NewCredentialCreationOptions(subject, address, chal))
|
return e.JSON(201, orm.NewCredentialCreationOptions(subject, address, chal))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterSubjectFinish handles the register subject finish.
|
||||||
func (a *authAPI) RegisterSubjectFinish(e echo.Context) error {
|
func (a *authAPI) RegisterSubjectFinish(e echo.Context) error {
|
||||||
// Deserialize the JSON into a temporary struct
|
// Deserialize the JSON into a temporary struct
|
||||||
var ccr protocol.CredentialCreationResponse
|
var ccr protocol.CredentialCreationResponse
|
||||||
@ -70,11 +80,3 @@ func (a *authAPI) RegisterSubjectFinish(e echo.Context) error {
|
|||||||
// // credential := orm.NewCredential(parsedData, e.Request().Host, "")
|
// // credential := orm.NewCredential(parsedData, e.Request().Host, "")
|
||||||
return e.JSON(201, ccr)
|
return e.JSON(201, ccr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ╭───────────────────────────────────────────────────────────╮
|
|
||||||
// │ Group Structures │
|
|
||||||
// ╰───────────────────────────────────────────────────────────╯
|
|
||||||
|
|
||||||
type authAPI struct{}
|
|
||||||
|
|
||||||
var Auth = new(authAPI)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user