mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 18:31:41 +00:00
refactor: move session management to dedicated database module
This commit is contained in:
@@ -2,12 +2,12 @@ package index
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gateway/session"
|
||||
"github.com/onsonr/sonr/internal/gateway/context"
|
||||
)
|
||||
|
||||
// Initial users have no authorization, user handle, or vault address
|
||||
func isInitial(c echo.Context) bool {
|
||||
sess, err := session.Get(c)
|
||||
sess, err := context.Get(c)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -17,7 +17,7 @@ func isInitial(c echo.Context) bool {
|
||||
|
||||
// Expired users have either a user handle or vault address
|
||||
func isExpired(c echo.Context) bool {
|
||||
sess, err := session.Get(c)
|
||||
sess, err := context.Get(c)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func isExpired(c echo.Context) bool {
|
||||
|
||||
// Returning users have a valid authorization, and either a user handle or vault address
|
||||
func isReturning(c echo.Context) bool {
|
||||
sess, err := session.Get(c)
|
||||
sess, err := context.Get(c)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gateway/database"
|
||||
"github.com/onsonr/sonr/internal/database/sessions"
|
||||
)
|
||||
|
||||
type CreateProfileData struct {
|
||||
@@ -35,8 +35,8 @@ func (d CreateProfileData) IsHumanLabel() string {
|
||||
return fmt.Sprintf("What is %d + %d?", d.FirstNumber, d.LastNumber)
|
||||
}
|
||||
|
||||
func extractCredentialDescriptor(jsonString string) (*database.Credential, error) {
|
||||
cred := &database.Credential{}
|
||||
func extractCredentialDescriptor(jsonString string) (*sessions.Credential, error) {
|
||||
cred := &sessions.Credential{}
|
||||
// Unmarshal the credential JSON
|
||||
if err := json.Unmarshal([]byte(jsonString), cred); err != nil {
|
||||
return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid credential format: %v", err))
|
||||
|
||||
Reference in New Issue
Block a user