Documentation ¶
Index ¶
- func DeleteEntry(tx *gorm.DB, id string) error
- func IncreaseVisitCounter(tx *gorm.DB, link *Link) error
- func IsDuplicatedEmail(tx *gorm.DB, email string) (bool, error)
- func IsNotFoundError(err error) bool
- func NewAuditLogEntry(tx *gorm.DB, actor *User, action AuditAction) error
- func UpdateRefreshToken(tx *gorm.DB, id uint, token string) error
- type AuditAction
- type AuditLogEntry
- type Link
- type Stats
- type User
- func FindUserByEmail(tx *gorm.DB, email string) (*User, error)
- func FindUserByID(tx *gorm.DB, id uint) (*User, error)
- func FindUserByToken(tx *gorm.DB, token string) (*User, error)
- func FindUsers(tx *gorm.DB) ([]*User, error)
- func NewUser(tx *gorm.DB, config *config.Configuration, email, password string) (*User, string, error)
- func (u *User) Authenticate(password string) bool
- func (u *User) BeforeCreate(scope *gorm.Scope) (err error)
- func (u *User) BeforeSave(scope *gorm.Scope) error
- func (u *User) ConfirmEmailChange(tx *gorm.DB) error
- func (u *User) Recover(tx *gorm.DB) error
- func (u *User) SetEmail(tx *gorm.DB, email string) error
- func (u *User) UpdatePassword(tx *gorm.DB, password string) error
- type UserNotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteEntry ¶ added in v0.2.3
DeleteEntry deleted an entry by a given ID and returns an error
func IncreaseVisitCounter ¶ added in v0.2.3
IncreaseVisitCounter increases the visit counter and sets the current
func IsDuplicatedEmail ¶ added in v0.2.3
IsDuplicatedEmail returns whether a user exists with a matching email.
func IsNotFoundError ¶ added in v0.2.3
IsNotFoundError returns whether an error represents a "not found" error.
func NewAuditLogEntry ¶ added in v0.2.3
func NewAuditLogEntry(tx *gorm.DB, actor *User, action AuditAction) error
NewAuditLogEntry creates a new audit entry
Types ¶
type AuditAction ¶ added in v0.2.3
type AuditAction string
AuditAction holds different action types as a string
const ( // LoginAction is a action type LoginAction AuditAction = "login" // LogoutAction is a action type LogoutAction AuditAction = "logout" // InviteAcceptedAction is a action type InviteAcceptedAction AuditAction = "invite_accepted" // UserSignedUpAction is a action type UserSignedUpAction AuditAction = "user_signedup" // UserDeletedAction is a action type UserDeletedAction AuditAction = "user_deleted" // UserModifiedAction is a action type UserModifiedAction AuditAction = "user_modified" // UserRecoveryRequestedAction is a action type UserRecoveryRequestedAction AuditAction = "user_recovery_requested" // TokenRevokedAction is a action type TokenRevokedAction AuditAction = "token_revoked" // TokenRefreshedAction is a action type TokenRefreshedAction AuditAction = "token_refreshed" )
type AuditLogEntry ¶ added in v0.2.3
type AuditLogEntry struct { ID uuid.UUID `json:"id" db:"id"` Timestamp string `json:"timestamp" db:"timestamp"` CreatedAt time.Time `json:"created_at" db:"created_at"` ActorID uint `json:"actor_id" db:"actor_id"` ActorEmail string `json:"actor_email" db:"actor_email"` Action AuditAction `json:"action" db:"action"` LogType auditLogType `json:"log_type" db:"log_type"` }
AuditLogEntry is the database model for audit log entries.
func (AuditLogEntry) TableName ¶ added in v0.2.3
func (AuditLogEntry) TableName() string
TableName returns the audit tablename
type Link ¶ added in v0.2.3
type Link struct { ID string `json:"id"` URL string `json:"url"` RemoteAddr string `json:",omitempty"` DeletionURL string `json:",omitempty"` Password []byte `json:",omitempty"` LastVisit *time.Time `json:"last_visit, omitempty"` Expiration *time.Time `json:"expiration,omitempty"` CreatedOn *time.Time `json:"-"` VisitCount int }
Link is the data for our "relinker-url-shortener"
func CreateEntry ¶ added in v0.2.3
CreateEntry creates an entry by a given ID and returns an error
func GetLinkByID ¶ added in v0.2.3
GetLinkByID returns a entry and an error by the shorted ID
func LinkUpdate ¶ added in v0.2.3
LinkUpdate updates URL of Link
type User ¶
type User struct { ID uint `json:"id" gorm:"primary_key"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"deleted_at" sql:"index"` Email string `json:"email" gorm:"unique;not null"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty"` TokenExpires time.Time `json:"token_expires"` RecoveryToken string `json:"-" db:"recovery_token"` RecoverySentAt *time.Time `json:"recovery_sent_at,omitempty" db:"recovery_sent_at"` EmailChangeToken string `json:"-" db:"email_change_token"` EmailChange string `json:"new_email,omitempty" db:"email_change"` EmailChangeSentAt *time.Time `json:"email_change_sent_at,omitempty" db:"email_change_sent_at"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` }
User is a user of our system
func FindUserByEmail ¶ added in v0.2.3
FindUserByEmail finds a user with the matching email.
func FindUserByID ¶ added in v0.2.3
FindUserByID finds a user matching the provided ID.
func FindUserByToken ¶ added in v0.2.3
FindUserByToken returns a user by it's refresh token
func NewUser ¶ added in v0.2.4
func NewUser(tx *gorm.DB, config *config.Configuration, email, password string) (*User, string, error)
NewUser creates a new User
func (*User) Authenticate ¶
func (*User) ConfirmEmailChange ¶ added in v0.2.3
ConfirmEmailChange confirm the change of email for a user
type UserNotFoundError ¶ added in v0.2.3
type UserNotFoundError struct{}
UserNotFoundError represents when a user is not found.
func (UserNotFoundError) Error ¶ added in v0.2.3
func (e UserNotFoundError) Error() string