2020-10-28 14:35:41 +01:00
|
|
|
package model
|
|
|
|
|
2021-08-10 04:57:45 +02:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2022-02-02 01:01:29 +01:00
|
|
|
const (
|
2022-08-29 09:25:12 +02:00
|
|
|
SingleUser = "single-user"
|
|
|
|
GlobalTeamID = "0"
|
|
|
|
SystemUserID = "system"
|
|
|
|
PreferencesCategoryFocalboard = "focalboard"
|
2022-02-02 01:01:29 +01:00
|
|
|
)
|
|
|
|
|
2021-02-17 20:29:20 +01:00
|
|
|
// User is a user
|
|
|
|
// swagger:model
|
2020-10-28 14:35:41 +01:00
|
|
|
type User struct {
|
2021-02-17 20:29:20 +01:00
|
|
|
// The user ID
|
|
|
|
// required: true
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
|
|
|
// The user name
|
|
|
|
// required: true
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
|
|
|
// The user's email
|
|
|
|
// required: true
|
2021-12-08 20:47:47 +01:00
|
|
|
Email string `json:"-"`
|
2021-02-17 20:29:20 +01:00
|
|
|
|
2022-07-08 16:43:43 +02:00
|
|
|
// The user's nickname
|
|
|
|
Nickname string `json:"nickname"`
|
|
|
|
// The user's first name
|
|
|
|
FirstName string `json:"firstname"`
|
|
|
|
// The user's last name
|
|
|
|
LastName string `json:"lastname"`
|
|
|
|
|
2021-02-17 20:29:20 +01:00
|
|
|
// swagger:ignore
|
|
|
|
Password string `json:"-"`
|
|
|
|
|
|
|
|
// swagger:ignore
|
|
|
|
MfaSecret string `json:"-"`
|
|
|
|
|
|
|
|
// swagger:ignore
|
|
|
|
AuthService string `json:"-"`
|
|
|
|
|
|
|
|
// swagger:ignore
|
|
|
|
AuthData string `json:"-"`
|
|
|
|
|
2022-04-15 19:21:10 +02:00
|
|
|
// Created time in miliseconds since the current epoch
|
2021-02-17 20:29:20 +01:00
|
|
|
// required: true
|
|
|
|
CreateAt int64 `json:"create_at,omitempty"`
|
|
|
|
|
2022-04-15 19:21:10 +02:00
|
|
|
// Updated time in miliseconds since the current epoch
|
2021-02-17 20:29:20 +01:00
|
|
|
// required: true
|
|
|
|
UpdateAt int64 `json:"update_at,omitempty"`
|
|
|
|
|
2022-04-15 19:21:10 +02:00
|
|
|
// Deleted time in miliseconds since the current epoch, set to indicate user is deleted
|
2021-02-17 20:29:20 +01:00
|
|
|
// required: true
|
|
|
|
DeleteAt int64 `json:"delete_at"`
|
2021-12-08 16:04:19 +01:00
|
|
|
|
|
|
|
// If the user is a bot or not
|
|
|
|
// required: true
|
|
|
|
IsBot bool `json:"is_bot"`
|
2022-04-04 16:00:40 +02:00
|
|
|
|
|
|
|
// If the user is a guest or not
|
|
|
|
// required: true
|
|
|
|
IsGuest bool `json:"is_guest"`
|
2022-06-29 14:35:24 +02:00
|
|
|
|
|
|
|
Roles string `json:"roles"`
|
2020-10-28 14:35:41 +01:00
|
|
|
}
|
2020-12-02 21:12:14 +01:00
|
|
|
|
2022-09-15 13:58:20 +02:00
|
|
|
// UserPreferencesPatch is a user property patch
|
2022-03-22 15:24:34 +01:00
|
|
|
// swagger:model
|
2022-09-15 13:58:20 +02:00
|
|
|
type UserPreferencesPatch struct {
|
|
|
|
// The user preference updated fields
|
2022-02-28 12:28:16 +01:00
|
|
|
// required: false
|
|
|
|
UpdatedFields map[string]string `json:"updatedFields"`
|
|
|
|
|
2022-09-15 13:58:20 +02:00
|
|
|
// The user preference removed fields
|
2022-02-28 12:28:16 +01:00
|
|
|
// required: false
|
|
|
|
DeletedFields []string `json:"deletedFields"`
|
|
|
|
}
|
|
|
|
|
2020-12-02 21:12:14 +01:00
|
|
|
type Session struct {
|
2021-03-26 19:01:54 +01:00
|
|
|
ID string `json:"id"`
|
|
|
|
Token string `json:"token"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
AuthService string `json:"authService"`
|
|
|
|
Props map[string]interface{} `json:"props"`
|
|
|
|
CreateAt int64 `json:"create_at,omitempty"`
|
|
|
|
UpdateAt int64 `json:"update_at,omitempty"`
|
2020-12-02 21:12:14 +01:00
|
|
|
}
|
2021-08-10 04:57:45 +02:00
|
|
|
|
|
|
|
func UserFromJSON(data io.Reader) (*User, error) {
|
|
|
|
var user User
|
|
|
|
if err := json.NewDecoder(data).Decode(&user); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &user, nil
|
|
|
|
}
|