models

package
v0.0.48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: GPL-3.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ErrLogEventIsNotSet  = "log event is not set"
	ErrLogEventTypeError = "log event type error"
)
View Source
const (
	LogEventType_LogIn   = 1
	LogEventType_LogOut  = 2 // Self logging out.
	LogEventType_LogOutA = 3 // Logging out by an administrator.
)
View Source
const (
	LogEventTypesCount = 3
)

Variables

This section is empty.

Functions

func CheckLogEvent

func CheckLogEvent(le *LogEvent) (err error)

Types

type ApproveAndRegisterUserParams

type ApproveAndRegisterUserParams struct {
	cmr.CommonParams

	// E-mail address of an approved user.
	Email string `json:"email"`
}

type ApproveAndRegisterUserResult

type ApproveAndRegisterUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type BanUserParams

type BanUserParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type BanUserResult

type BanUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type ChangeEmailParams

type ChangeEmailParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// New e-mail address.
	// Is used on step 1.
	NewEmail string `json:"newEmail"`

	// Request ID.
	// It protects e-mail changes from being hi-jacked.
	// Is used on step 2.
	RequestId string `json:"requestId"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code for the old e-mail.
	// Is used on step 2.
	VerificationCodeOld string `json:"verificationCodeOld"`

	// Verification Code for the new e-mail.
	// Is used on step 2.
	VerificationCodeNew string `json:"verificationCodeNew"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`
}

type ChangeEmailResult

type ChangeEmailResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// Success flag.
	OK bool `json:"ok"`
}

type ChangePasswordParams

type ChangePasswordParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// New password.
	// Is used on step 1.
	NewPassword string `json:"newPassword"`

	// Request ID.
	// It protects password changes from being hi-jacked.
	// Is used on step 2.
	RequestId string `json:"requestId"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code.
	// Is used on step 2.
	VerificationCode string `json:"verificationCode"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`
}

type ChangePasswordResult

type ChangePasswordResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// Success flag.
	OK bool `json:"ok"`
}

type EmailChange

type EmailChange struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      *string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes     []byte
	IsCaptchaRequired bool
	CaptchaId         sql.NullString
	EmailChangeVerificationFlags

	// Old e-mail.
	VerificationCodeOld *string
	IsOldEmailSent      bool

	// New e-mail.
	NewEmail            string
	VerificationCodeNew *string
	IsNewEmailSent      bool
}

func NewEmailChange

func NewEmailChange() (ec *EmailChange)

func NewEmailChangeFromScannableSource

func NewEmailChangeFromScannableSource(src cm.IScannable) (ec *EmailChange, err error)

type EmailChangeVerificationFlags

type EmailChangeVerificationFlags struct {
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	IsVerifiedByOldEmail bool
	IsVerifiedByNewEmail bool
}

type GetListOfAllUsersParams added in v0.0.16

type GetListOfAllUsersParams struct {
	cmr.CommonParams

	Page uint `json:"page"`
}

type GetListOfAllUsersResult added in v0.0.16

type GetListOfAllUsersResult struct {
	cmr.CommonResult

	UserIds    []uint `json:"userIds"`
	Page       uint   `json:"page,omitempty"`
	TotalPages uint   `json:"totalPages,omitempty"`
	TotalUsers uint   `json:"totalUsers,omitempty"`
}

type GetListOfLoggedUsersParams

type GetListOfLoggedUsersParams struct {
	cmr.CommonParams
}

type GetListOfLoggedUsersResult

type GetListOfLoggedUsersResult struct {
	cmr.CommonResult

	LoggedUserIds []uint `json:"loggedUserIds"`
}

type GetListOfRegistrationsReadyForApprovalParams added in v0.0.21

type GetListOfRegistrationsReadyForApprovalParams struct {
	cmr.CommonParams

	Page uint `json:"page"`
}

type GetListOfRegistrationsReadyForApprovalResult added in v0.0.21

type GetListOfRegistrationsReadyForApprovalResult struct {
	cmr.CommonResult

	RRFA         []RegistrationReadyForApproval `json:"rrfa"`
	Page         uint                           `json:"page,omitempty"`
	TotalPages   uint                           `json:"totalPages,omitempty"`
	TotalRecords uint                           `json:"totalRecords,omitempty"`
}

type GetSelfRolesParams

type GetSelfRolesParams struct {
	cmr.CommonParams
}

type GetSelfRolesResult

type GetSelfRolesResult struct {
	cmr.CommonResult

	UserId  uint      `json:"userId"`
	Name    string    `json:"name"`
	Email   string    `json:"email"`
	RegTime time.Time `json:"regTime"`
	cm.UserRoles
}

type GetUserNameParams added in v0.0.38

type GetUserNameParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type GetUserNameResult added in v0.0.38

type GetUserNameResult struct {
	cmr.CommonResult

	UserId   uint   `json:"userId"`
	UserName string `json:"userName"`
}

type GetUserRolesParams

type GetUserRolesParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type GetUserRolesResult

type GetUserRolesResult struct {
	cmr.CommonResult

	UserId uint `json:"userId"`
	cm.UserRoles
}

type GetUserSessionParams added in v0.0.27

type GetUserSessionParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type GetUserSessionResult added in v0.0.27

type GetUserSessionResult struct {
	cmr.CommonResult

	Session *Session `json:"session"`
}

type IsUserLoggedInParams

type IsUserLoggedInParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type IsUserLoggedInResult

type IsUserLoggedInResult struct {
	cmr.CommonResult

	UserId         uint `json:"userId"`
	IsUserLoggedIn bool `json:"isUserLoggedIn"`
}

type LogEvent

type LogEvent struct {
	Id       uint
	Time     time.Time
	Type     LogEventType
	UserId   uint
	Email    string
	UserIPAB net.IP

	// ID of administrator for those events which were started by an
	// administrator.
	AdminId *uint
}

type LogEventType

type LogEventType byte

func (LogEventType) IsValid

func (let LogEventType) IsValid() (ok bool)

type LogUserInParams

type LogUserInParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// E-mail address.
	// This is the main identifier of a user.
	// It is used on all steps.
	Email string `json:"email"`

	// Request ID.
	// It protects preliminary sessions from being hi-jacked.
	// Is used on steps 2 and 3.
	RequestId string `json:"requestId"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code.
	// Is used on step 3.
	VerificationCode string `json:"verificationCode"`
}

type LogUserInResult

type LogUserInResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// JWT key maker.
	IsWebTokenSet bool   `json:"isWebTokenSet"`
	WTS           string `json:"wts,omitempty"` // Web token string.
}

type LogUserOutAParams added in v0.0.24

type LogUserOutAParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type LogUserOutAResult added in v0.0.24

type LogUserOutAResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type LogUserOutParams

type LogUserOutParams struct {
	cmr.CommonParams
}

type LogUserOutResult

type LogUserOutResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type PasswordChange

type PasswordChange struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      *string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes        []byte
	IsCaptchaRequired    bool
	CaptchaId            sql.NullString
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	VerificationCode     *string
	IsEmailSent          bool
	IsVerifiedByEmail    bool
	NewPassword          []byte
}

func NewPasswordChange

func NewPasswordChange() (pc *PasswordChange)

func NewPasswordChangeFromScannableSource

func NewPasswordChangeFromScannableSource(src cm.IScannable) (pc *PasswordChange, err error)

type PasswordChangeVerificationFlags

type PasswordChangeVerificationFlags struct {
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	IsVerifiedByEmail    bool
}

type PingParams

type PingParams = cmr.PingParams

type PingResult

type PingResult = cmr.PingResult

type PreSession

type PreSession struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes        []byte
	IsCaptchaRequired    bool
	CaptchaId            sql.NullString
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool

	// Verification code is set on Step 2, so it is NULL on Step 1.
	VerificationCode sql.NullString

	IsEmailSent       bool
	IsVerifiedByEmail bool
}

func NewPreSession

func NewPreSession() (ps *PreSession)

func NewPreSessionFromScannableSource

func NewPreSessionFromScannableSource(src cm.IScannable) (ps *PreSession, err error)

type RegisterUserParams

type RegisterUserParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// E-mail address.
	// Is used on steps 1, 2 and 3.
	Email string `json:"email"`

	// Verification code.
	// Is used on steps 2 and 3.
	VerificationCode string `json:"verificationCode"`

	// Name.
	// Is used on step 3.
	Name string `json:"name"`

	// Password.
	// Is used on step 3.
	Password string `json:"password"`
}

type RegisterUserResult

type RegisterUserResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`
}

type RegistrationReadyForApproval added in v0.0.21

type RegistrationReadyForApproval struct {
	Id         uint   `json:"id"`
	PreRegTime string `json:"preRegTime"`
	Email      string `json:"email"`
	Name       string `json:"name"`
}

RegistrationReadyForApproval is a short variant of an object representing a request for registration which is ready to be approved.

func NewRegistrationReadyForApproval added in v0.0.21

func NewRegistrationReadyForApproval() (r *RegistrationReadyForApproval)

func NewRegistrationReadyForApprovalFromScannableSource added in v0.0.21

func NewRegistrationReadyForApprovalFromScannableSource(src cm.IScannable) (r *RegistrationReadyForApproval, err error)

type RejectRegistrationRequestParams added in v0.0.22

type RejectRegistrationRequestParams struct {
	cmr.CommonParams

	// ID of a registration request.
	Id uint `json:"id"`
}

type RejectRegistrationRequestResult added in v0.0.22

type RejectRegistrationRequestResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type RequestId

type RequestId = uint

type Session

type Session struct {
	Id        uint      `json:"id"`
	UserId    uint      `json:"userId"`
	StartTime time.Time `json:"startTime"`

	// IP address of a user. B = Byte array.
	UserIPAB net.IP `json:"userIPA"`
}

func NewSession

func NewSession() (s *Session)

func NewSessionFromScannableSource

func NewSessionFromScannableSource(src cm.IScannable) (s *Session, err error)

type SetUserRoleAuthorParams

type SetUserRoleAuthorParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleAuthorResult

type SetUserRoleAuthorResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type SetUserRoleReaderParams

type SetUserRoleReaderParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleReaderResult

type SetUserRoleReaderResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type SetUserRoleWriterParams

type SetUserRoleWriterParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleWriterResult

type SetUserRoleWriterResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type ShowDiagnosticDataParams

type ShowDiagnosticDataParams struct{}

type ShowDiagnosticDataResult

type ShowDiagnosticDataResult struct {
	cmr.CommonResult
	cmr.RequestsCount
}

type TestParams

type TestParams struct{}

type TestResult

type TestResult struct {
	cmr.CommonResult
}

type UnbanUserParams

type UnbanUserParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type UnbanUserResult

type UnbanUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type User

type User struct {
	Password string `json:"-"`
	cm.UserParameters
}

func NewUser

func NewUser() (u *User)

func NewUserFromScannableSource

func NewUserFromScannableSource(src cm.IScannable) (u *User, err error)

type UserData

type UserData struct {
	User    *User
	Session *Session
}

func NewUserData

func NewUserData() (ud *UserData)

type ViewUserParametersParams

type ViewUserParametersParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type ViewUserParametersResult

type ViewUserParametersResult struct {
	cmr.CommonResult

	cm.UserParameters
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL