serve frontend from go
This commit is contained in:
37
internal/model/auth.go
Normal file
37
internal/model/auth.go
Normal file
@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
RoleAdmin Role = " admin"
|
||||
RoleUser Role = "user"
|
||||
RoleGuest Role = "guest"
|
||||
)
|
||||
|
||||
// InvalidJWT Represents a JWT that has expired or is otherwise invalid.
|
||||
type InvalidJWT struct {
|
||||
JWT string `gorm:"primarykey"`
|
||||
ValidUntil time.Time
|
||||
}
|
||||
|
||||
// User represents a user with an ID, UUID, name, role, and password.
|
||||
type User struct {
|
||||
ID uint `gorm:"primarykey" json:"-"`
|
||||
UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`
|
||||
Name string `json:"name" gorm:"unique"`
|
||||
Role Role `json:"role"`
|
||||
Password []byte `json:"-"`
|
||||
}
|
||||
|
||||
// NewUser creates a new User struct with a generated UUID.
|
||||
func NewUser() User {
|
||||
return User{
|
||||
UUID: uuid.New(),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user