2021-02-24 21:24:45 +01:00
|
|
|
package users
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UserSource string
|
|
|
|
|
|
|
|
const (
|
|
|
|
UserSourceLdap UserSource = "ldap" // LDAP / ActiveDirectory
|
|
|
|
UserSourceDatabase UserSource = "db" // sqlite / mysql database
|
|
|
|
)
|
|
|
|
|
2021-04-26 22:00:50 +02:00
|
|
|
type PrivateString string
|
|
|
|
|
|
|
|
func (PrivateString) MarshalJSON() ([]byte, error) {
|
|
|
|
return []byte(`""`), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (PrivateString) String() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-02-24 21:24:45 +01:00
|
|
|
// User is the user model that gets linked to peer entries, by default an empty usermodel with only the email address is created
|
|
|
|
type User struct {
|
|
|
|
// required fields
|
|
|
|
Email string `gorm:"primaryKey" form:"email" binding:"required,email"`
|
|
|
|
Source UserSource
|
2022-03-15 23:34:55 +01:00
|
|
|
IsAdmin bool `form:"isadmin"`
|
2021-02-24 21:24:45 +01:00
|
|
|
|
|
|
|
// optional fields
|
|
|
|
Firstname string `form:"firstname" binding:"required"`
|
|
|
|
Lastname string `form:"lastname" binding:"required"`
|
|
|
|
Phone string `form:"phone" binding:"omitempty"`
|
|
|
|
|
|
|
|
// optional, integrated password authentication
|
2021-04-26 22:00:50 +02:00
|
|
|
Password PrivateString `form:"password" binding:"omitempty"`
|
2021-02-24 21:24:45 +01:00
|
|
|
|
|
|
|
// database internal fields
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
2021-09-29 18:41:13 +02:00
|
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:",omitempty" swaggertype:"string"`
|
2021-02-24 21:24:45 +01:00
|
|
|
}
|