2015-01-19 09:28:45 -06:00
|
|
|
package models
|
|
|
|
|
2015-01-19 11:01:04 -06:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
|
|
|
ErrUserNotFound = errors.New("User not found")
|
|
|
|
)
|
2015-01-19 09:28:45 -06:00
|
|
|
|
|
|
|
type User struct {
|
2015-02-12 03:32:22 -06:00
|
|
|
Id int64
|
|
|
|
Version int
|
|
|
|
Email string
|
|
|
|
Name string
|
|
|
|
Login string
|
|
|
|
Password string
|
|
|
|
Salt string
|
|
|
|
Rands string
|
|
|
|
Company string
|
|
|
|
EmailVerified bool
|
|
|
|
Theme string
|
2015-01-19 09:28:45 -06:00
|
|
|
|
2015-02-23 13:07:49 -06:00
|
|
|
IsAdmin bool
|
|
|
|
OrgId int64
|
2015-01-19 09:28:45 -06:00
|
|
|
|
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
|
|
|
type CreateUserCommand struct {
|
2015-01-21 02:52:40 -06:00
|
|
|
Email string `json:"email" binding:"Required"`
|
|
|
|
Login string `json:"login"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Company string `json:"compay"`
|
|
|
|
Password string `json:"password" binding:"Required"`
|
|
|
|
IsAdmin bool `json:"-"`
|
2015-01-19 09:28:45 -06:00
|
|
|
|
|
|
|
Result User `json:"-"`
|
|
|
|
}
|
2015-01-19 11:01:04 -06:00
|
|
|
|
|
|
|
type UpdateUserCommand struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Login string `json:"login"`
|
2015-02-28 07:30:08 -06:00
|
|
|
Theme string `json:"theme"`
|
2015-01-19 11:01:04 -06:00
|
|
|
|
|
|
|
UserId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:09:49 -06:00
|
|
|
type ChangeUserPasswordCommand struct {
|
|
|
|
OldPassword string `json:"oldPassword"`
|
|
|
|
NewPassword string `json:"newPassword"`
|
|
|
|
|
|
|
|
UserId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
2015-02-26 08:43:48 -06:00
|
|
|
type UpdateUserPermissionsCommand struct {
|
|
|
|
IsGrafanaAdmin bool
|
|
|
|
UserId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
2015-02-11 09:47:22 -06:00
|
|
|
type DeleteUserCommand struct {
|
|
|
|
UserId int64
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:07:49 -06:00
|
|
|
type SetUsingOrgCommand struct {
|
|
|
|
UserId int64
|
|
|
|
OrgId int64
|
2015-01-19 11:01:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// QUERIES
|
|
|
|
|
|
|
|
type GetUserByLoginQuery struct {
|
|
|
|
LoginOrEmail string
|
|
|
|
Result *User
|
|
|
|
}
|
|
|
|
|
2015-02-10 08:36:51 -06:00
|
|
|
type GetUserByIdQuery struct {
|
|
|
|
Id int64
|
|
|
|
Result *User
|
|
|
|
}
|
|
|
|
|
2015-01-19 11:01:04 -06:00
|
|
|
type GetSignedInUserQuery struct {
|
|
|
|
UserId int64
|
2015-05-02 05:06:58 -05:00
|
|
|
Login string
|
|
|
|
Email string
|
2015-01-19 11:01:04 -06:00
|
|
|
Result *SignedInUser
|
|
|
|
}
|
|
|
|
|
2015-02-28 07:30:08 -06:00
|
|
|
type GetUserProfileQuery struct {
|
2015-01-19 11:01:04 -06:00
|
|
|
UserId int64
|
2015-02-28 07:30:08 -06:00
|
|
|
Result UserProfileDTO
|
2015-01-19 11:01:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type SearchUsersQuery struct {
|
|
|
|
Query string
|
|
|
|
Page int
|
|
|
|
Limit int
|
|
|
|
|
|
|
|
Result []*UserSearchHitDTO
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:07:49 -06:00
|
|
|
type GetUserOrgListQuery struct {
|
|
|
|
UserId int64
|
|
|
|
Result []*UserOrgDTO
|
|
|
|
}
|
|
|
|
|
2015-01-19 11:01:04 -06:00
|
|
|
// ------------------------
|
|
|
|
// DTO & Projections
|
|
|
|
|
|
|
|
type SignedInUser struct {
|
|
|
|
UserId int64
|
2015-02-23 13:07:49 -06:00
|
|
|
OrgId int64
|
|
|
|
OrgName string
|
|
|
|
OrgRole RoleType
|
2015-01-19 11:01:04 -06:00
|
|
|
Login string
|
|
|
|
Name string
|
|
|
|
Email string
|
2015-02-28 07:30:08 -06:00
|
|
|
Theme string
|
2015-01-19 11:01:04 -06:00
|
|
|
ApiKeyId int64
|
|
|
|
IsGrafanaAdmin bool
|
|
|
|
}
|
|
|
|
|
2015-02-28 07:30:08 -06:00
|
|
|
type UserProfileDTO struct {
|
2015-02-26 08:43:48 -06:00
|
|
|
Email string `json:"email"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Login string `json:"login"`
|
2015-02-28 07:30:08 -06:00
|
|
|
Theme string `json:"theme"`
|
2015-02-26 08:43:48 -06:00
|
|
|
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
|
2015-01-19 11:01:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type UserSearchHitDTO struct {
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Login string `json:"login"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
IsAdmin bool `json:"isAdmin"`
|
|
|
|
}
|