models

package
v0.0.0-...-aace954 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssetType_User        = "user"
	AssetType_Application = "application"
)

Variables

This section is empty.

Functions

func NormalizeContactPrincipal

func NormalizeContactPrincipal(contactType, contactPrincipal string) string

func ValidateApp

func ValidateApp(includeID bool, app App) errors.RichError

func ValidateScope

func ValidateScope(includeID bool, scope Scope) errors.RichError

Types

type Address

type Address struct {
	ID         string                  `bson:"-"`
	UserID     string                  `bson:"-"`
	Name       nullable.NullableString `bson:"name"`
	Line1      string                  `bson:"line1"`
	Line2      nullable.NullableString `bson:"line2"`
	City       string                  `bson:"city"`
	State      string                  `bson:"state"`
	PostalCode string                  `bson:"postalCode"`
	IsPrimary  bool                    `bson:"isPrimary"`
	// contains filtered or unexported fields
}

TODO: Add validator for pre insert / update Address is a physical address.

func NewAddress

func NewAddress(userID, name, line1, line2, city, state, postalCode string, isPiramry bool) Address

type App

type App struct {
	ID               string    `bson:"-"`
	OwnerID          string    `bson:"-"`
	Name             string    `bson:"name"`
	ClientID         string    `bson:"clientId"`
	ClientSecretHash string    `bson:"clientSecret"`
	CallbackURI      string    `bson:"callbackUri"`
	IsDisabled       bool      `bson:"isDisabled"`
	LogoURI          string    `bson:"logoUri"`
	AuditData        auditable `bson:",inline"`
}

func NewApp

func NewApp(ownerID, name, callbackURI, logoURI string) (App, string, errors.RichError)

type AuditLog

type AuditLog struct {
	ID           string                 `bson:"id"`
	Message      string                 `bson:"message"`
	Code         string                 `bson:"code"`
	AssetType    string                 `bson:"assetType"`
	AssetID      string                 `bson:"assetId"`
	AuditLogDate time.Time              `bson:"auditLogDate"`
	Data         map[string]interface{} `bson:"data"`
}

type Contact

type Contact struct {
	ID           string                  `bson:"-"`
	UserID       string                  `bson:"-"`
	Name         nullable.NullableString `bson:"name"`
	RawPrincipal string                  `bson:"rawPrincipal"`
	Principal    string                  `bson:"principal"`
	Type         string                  `bson:"type"`
	IsPrimary    bool                    `bson:"isPrimary"`
	// ConfirmationCode nullable.NullableString `bson:"confirmationCode"`
	ConfirmedDate nullable.NullableTime `bson:"confirmedDate"`
	AuditData     auditable             `bson:",inline"`
}

TODO: Add validator for pre insert / update TODO: determine if the confirmation code needs an expiration date? or use redis for these short lived tokens? Contact is a model that represents a contact method for a user like phone or email.

func NewContact

func NewContact(userID, name, principal, contactType string, isPrimary bool) Contact

TODO: write unit tests

func (*Contact) IsConfirmed

func (c *Contact) IsConfirmed() bool

type LogLevel

type LogLevel int
const (
	DEBUG LogLevel = iota
	INFORMATION
	WARNING
	ERROR
	CRITICAL
)

func (LogLevel) ToString

func (ll LogLevel) ToString() string

type Profile

type Profile struct {
	ID          string                  `bson:"-"`
	UserID      string                  `bson:"-"`
	FirstName   nullable.NullableString `bson:"firstName"`
	MiddleName  nullable.NullableString `bson:"middleName"`
	LastName    nullable.NullableString `bson:"lastName"`
	DateOfBirth nullable.NullableTime   `bson:"dateOfBirth"`
	// contains filtered or unexported fields
}

TODO: Add validator for pre insert / update Profile represents personal profile data for a given user.

func NewProfile

func NewProfile(userID, firstName, middleName, lastName string, dateOfBirth time.Time) Profile

type Scope

type Scope struct {
	ID          string    `bson:"-"`
	AppID       string    `bson:"-"`
	Name        string    `bson:"name"`
	Description string    `bson:"description"`
	AuditData   auditable `bson:",inline"`
}

func NewScope

func NewScope(appID, name, description string) Scope

type Token

type Token struct {
	// Value needs to a be a universially unique value like a uuid or something like that. This is the token passed around.
	Value string
	// TokenType is the type of token the token is.
	TokenType TokenType
	// Expiration is the time at which the token expires. all tokens must expire, so this must have a value.
	Expiration time.Time
	// TargetID is to specify the entity to who the token applies. if the token can be accessed anonymously, leave this blank.
	TargetID string
	// MetaData is a map that contains general purpose data related to a token.
	MetaData map[string]string
}

Token is a temporary item that can be used as a shared secret like a password reset token or a confirm contact token. They can be tide to a target entity like a user to ensure they are consumed by the proper targets.

func NewToken

func NewToken(targetID string, tokenType TokenType, validFor time.Duration) (Token, errors.RichError)

func (*Token) AddMetaData

func (t *Token) AddMetaData(key, value string)

func (Token) IsExpired

func (t Token) IsExpired() bool

func (*Token) WithMetaData

func (t *Token) WithMetaData(metaData map[string]string)

type TokenType

type TokenType int
const (
	TokenTypeInvalid TokenType = iota
	TokenTypeCSRF
	TokenTypeConfirmContact
	TokenTypePasswordReset
	TokenTypeSession
)

func (TokenType) String

func (i TokenType) String() string

type User

type User struct {
	ID                             string                `bson:"-"`
	PasswordHash                   string                `bson:"passwordHash"`
	ConsecutiveFailedLoginAttempts int                   `bson:"consecutiveFailedLoginAttempts"`
	LockedOutUntil                 nullable.NullableTime `bson:"lockedOutUntil"`
	LastLoginDate                  nullable.NullableTime `bson:"lastLoginDate"`
	// PasswordResetToken             nullable.NullableString `bson:"passwordResetToken"`
	// PasswordResetTokenExpiration   nullable.NullableTime   `bson:"passwordResetTokenExpiration"`
	AuditData auditable `bson:",inline"`
}

TODO: Add validator for pre insert / update User represents a user in the system.

func NewUser

func NewUser() User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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