2015-07-16 10:59:11 -05:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2022-08-10 04:56:48 -05:00
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/org"
|
2015-07-16 10:59:11 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
2022-06-28 07:32:25 -05:00
|
|
|
ErrTempUserNotFound = errors.New("user not found")
|
2015-07-16 10:59:11 -05:00
|
|
|
)
|
|
|
|
|
2015-07-20 03:57:39 -05:00
|
|
|
type TempUserStatus string
|
|
|
|
|
|
|
|
const (
|
2015-08-27 06:59:58 -05:00
|
|
|
TmpUserSignUpStarted TempUserStatus = "SignUpStarted"
|
2015-07-20 03:57:39 -05:00
|
|
|
TmpUserInvitePending TempUserStatus = "InvitePending"
|
|
|
|
TmpUserCompleted TempUserStatus = "Completed"
|
|
|
|
TmpUserRevoked TempUserStatus = "Revoked"
|
2020-10-13 05:30:09 -05:00
|
|
|
TmpUserExpired TempUserStatus = "Expired"
|
2015-07-20 03:57:39 -05:00
|
|
|
)
|
|
|
|
|
2015-07-17 02:51:34 -05:00
|
|
|
// TempUser holds data for org invites and unconfirmed sign ups
|
2015-07-16 10:59:11 -05:00
|
|
|
type TempUser struct {
|
2015-07-17 02:51:34 -05:00
|
|
|
Id int64
|
|
|
|
OrgId int64
|
|
|
|
Version int
|
|
|
|
Email string
|
|
|
|
Name string
|
2022-08-10 04:56:48 -05:00
|
|
|
Role org.RoleType
|
2015-07-17 02:51:34 -05:00
|
|
|
InvitedByUserId int64
|
2015-07-20 03:57:39 -05:00
|
|
|
Status TempUserStatus
|
2015-07-16 10:59:11 -05:00
|
|
|
|
|
|
|
EmailSent bool
|
|
|
|
EmailSentOn time.Time
|
|
|
|
Code string
|
2015-07-20 03:57:39 -05:00
|
|
|
RemoteAddr string
|
2015-07-16 10:59:11 -05:00
|
|
|
|
2020-10-13 05:30:09 -05:00
|
|
|
Created int64
|
|
|
|
Updated int64
|
2015-07-16 10:59:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
|
|
|
type CreateTempUserCommand struct {
|
2015-07-17 02:51:34 -05:00
|
|
|
Email string
|
|
|
|
Name string
|
|
|
|
OrgId int64
|
|
|
|
InvitedByUserId int64
|
2015-07-20 03:57:39 -05:00
|
|
|
Status TempUserStatus
|
2015-07-17 02:51:34 -05:00
|
|
|
Code string
|
2022-08-10 04:56:48 -05:00
|
|
|
Role org.RoleType
|
2015-07-20 03:57:39 -05:00
|
|
|
RemoteAddr string
|
2015-07-16 10:59:11 -05:00
|
|
|
|
|
|
|
Result *TempUser
|
|
|
|
}
|
|
|
|
|
2015-07-20 03:57:39 -05:00
|
|
|
type UpdateTempUserStatusCommand struct {
|
2015-07-20 10:46:48 -05:00
|
|
|
Code string
|
2015-07-20 03:57:39 -05:00
|
|
|
Status TempUserStatus
|
|
|
|
}
|
|
|
|
|
2020-10-13 05:30:09 -05:00
|
|
|
type ExpireTempUsersCommand struct {
|
|
|
|
OlderThan time.Time
|
|
|
|
|
|
|
|
NumExpired int64
|
|
|
|
}
|
|
|
|
|
2017-06-30 13:21:05 -05:00
|
|
|
type UpdateTempUserWithEmailSentCommand struct {
|
|
|
|
Code string
|
|
|
|
}
|
|
|
|
|
2015-08-28 08:14:24 -05:00
|
|
|
type GetTempUsersQuery struct {
|
2015-07-20 03:57:39 -05:00
|
|
|
OrgId int64
|
2015-08-28 08:14:24 -05:00
|
|
|
Email string
|
2015-07-20 03:57:39 -05:00
|
|
|
Status TempUserStatus
|
2015-07-16 10:59:11 -05:00
|
|
|
|
|
|
|
Result []*TempUserDTO
|
|
|
|
}
|
|
|
|
|
2015-07-20 10:46:48 -05:00
|
|
|
type GetTempUserByCodeQuery struct {
|
2015-07-20 08:52:49 -05:00
|
|
|
Code string
|
|
|
|
|
2015-08-10 06:46:59 -05:00
|
|
|
Result *TempUserDTO
|
2015-07-20 08:52:49 -05:00
|
|
|
}
|
|
|
|
|
2015-07-16 10:59:11 -05:00
|
|
|
type TempUserDTO struct {
|
2015-08-10 06:46:59 -05:00
|
|
|
Id int64 `json:"id"`
|
2015-08-11 03:45:03 -05:00
|
|
|
OrgId int64 `json:"orgId"`
|
2015-08-10 06:46:59 -05:00
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"email"`
|
2022-08-10 04:56:48 -05:00
|
|
|
Role org.RoleType `json:"role"`
|
2015-08-10 06:46:59 -05:00
|
|
|
InvitedByLogin string `json:"invitedByLogin"`
|
|
|
|
InvitedByEmail string `json:"invitedByEmail"`
|
|
|
|
InvitedByName string `json:"invitedByName"`
|
|
|
|
Code string `json:"code"`
|
|
|
|
Status TempUserStatus `json:"status"`
|
|
|
|
Url string `json:"url"`
|
|
|
|
EmailSent bool `json:"emailSent"`
|
|
|
|
EmailSentOn time.Time `json:"emailSentOn"`
|
|
|
|
Created time.Time `json:"createdOn"`
|
2015-07-16 10:59:11 -05:00
|
|
|
}
|