add users
This commit is contained in:
@ -1,9 +1,34 @@
|
||||
package model
|
||||
|
||||
type Login struct {
|
||||
Name string `json:"name"`
|
||||
Password string `json:"Password"`
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
RoleAdmin Role = " admin"
|
||||
RoleUser Role = "user"
|
||||
RoleGuest Role = "guest"
|
||||
)
|
||||
|
||||
type InvalidJWT struct {
|
||||
JWT string `gorm:"primarykey"`
|
||||
ValidUntil time.Time
|
||||
}
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
|
||||
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:"-"`
|
||||
}
|
||||
|
||||
func NewUser() User {
|
||||
return User{
|
||||
UUID: uuid.New(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user