Files
sonr/pkg/gateway/internal/database/models.go
T
Prad NukalaandGitHub 38447af730 feature/data persistence (#1180)
- **feat: add documentation and GitHub Actions workflow for publishing
documentation**
- **docs(concepts): add documentation for chain modules**
- **refactor: Simplify session management with SQLite storage and remove
deprecated code**
- **refactor: Simplify database initialization and remove
DatabaseContext**
- **refactor: move connection handling logic to resolver package**
- **feat: implement session management with database persistence**
- **feat: Ensure config directory exists when creating database path**
- **feat: Add SetUserHandle function to set user handle in session**
- **feat: Add public methods to set session fields with database save**
- **refactor: Remove unused session setter functions**
- **feat: Add getter methods for all Session Model properties**
- **feat: enhance Session model with user name details**
- **feat: add Motr support and update UI elements**
- **<no value>**
- **feat: Add unique handle constraint and method to check handle
existence**
- **docs: update site URL to onsonr.dev**
- **fix: correct import statement for database package**
- **test: updated CI to run tests on pull requests and merge groups**
- **docs: remove reference to develop branch in workflow**
- **feat: add WebAuthn support for user registration**
- **fix: correct smart account attenuation preset name**
- **feat: add ComputeIssuerDID and ComputeSonrAddr functions to ucan
package**
- **test: add unit tests for MPC keyset and keyshare**
- **feat: introduce new script to streamline GitHub issue creation**
2024-12-06 21:31:20 -05:00

42 lines
1.3 KiB
Go

package database
import (
"net/http"
"github.com/labstack/echo/v4"
"gorm.io/gorm"
)
var (
ErrInvalidCredentials = echo.NewHTTPError(http.StatusUnauthorized, "Invalid credentials")
ErrInvalidSubject = echo.NewHTTPError(http.StatusBadRequest, "Invalid subject")
ErrInvalidUser = echo.NewHTTPError(http.StatusBadRequest, "Invalid user")
ErrUserAlreadyExists = echo.NewHTTPError(http.StatusConflict, "User already exists")
ErrUserNotFound = echo.NewHTTPError(http.StatusNotFound, "User not found")
)
type User struct {
gorm.Model
Address string `json:"address"`
Handle string `json:"handle"`
FirstName string `json:"firstName"`
LastInitial string `json:"lastInitial"`
VaultCID string `json:"vaultCID"`
}
type Session struct {
gorm.Model
ID string `json:"id" gorm:"primaryKey"`
BrowserName string `json:"browserName"`
BrowserVersion string `json:"browserVersion"`
UserArchitecture string `json:"userArchitecture"`
Platform string `json:"platform"`
PlatformVersion string `json:"platformVersion"`
DeviceModel string `json:"deviceModel"`
UserHandle string `json:"userHandle"`
FirstName string `json:"firstName"`
LastInitial string `json:"lastInitial"`
VaultAddress string `json:"vaultAddress"`
}