models

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2017 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateAll

func MigrateAll(db *gorm.DB) error

MigrateAll executes all migrations

func OauthAccessTokenPreload

func OauthAccessTokenPreload(db *gorm.DB) *gorm.DB

OauthAccessTokenPreload sets up Gorm preloads for an access token object

func OauthAccessTokenPreloadWithPrefix

func OauthAccessTokenPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB

OauthAccessTokenPreloadWithPrefix sets up Gorm preloads for an access token object, and prefixes with prefix for nested objects

func OauthAuthorizationCodePreload

func OauthAuthorizationCodePreload(db *gorm.DB) *gorm.DB

OauthAuthorizationCodePreload sets up Gorm preloads for an auth code object

func OauthAuthorizationCodePreloadWithPrefix

func OauthAuthorizationCodePreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB

OauthAuthorizationCodePreloadWithPrefix sets up Gorm preloads for an auth code object, and prefixes with prefix for nested objects

func OauthRefreshTokenPreload

func OauthRefreshTokenPreload(db *gorm.DB) *gorm.DB

OauthRefreshTokenPreload sets up Gorm preloads for a refresh token object

func OauthRefreshTokenPreloadWithPrefix

func OauthRefreshTokenPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB

OauthRefreshTokenPreloadWithPrefix sets up Gorm preloads for a refresh token object, and prefixes with prefix for nested objects

Types

type EmailTokenModel

type EmailTokenModel struct {
	MyGormModel
	Reference   string `sql:"type:varchar(40);unique;not null"`
	EmailSent   bool   `sql:"index;not null"`
	EmailSentAt *time.Time
	ExpiresAt   time.Time `sql:"index;not null"`
}

EmailTokenModel is an abstract model which can be used for objects from which we derive redirect emails (email confirmation, password reset and such)

type MyGormModel

type MyGormModel struct {
	ID        string `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

MyGormModel mimixks GormModel but uses uuid's for ID, generated in go

type OauthAccessToken

type OauthAccessToken struct {
	MyGormModel
	ClientID  sql.NullString `sql:"index;not null"`
	UserID    sql.NullString `sql:"index"`
	Client    *OauthClient
	User      *OauthUser
	Token     string    `sql:"type:varchar(40);unique;not null"`
	ExpiresAt time.Time `sql:"not null"`
	Scope     string    `sql:"type:varchar(200);not null"`
}

OauthAccessToken ...

func NewOauthAccessToken

func NewOauthAccessToken(client *OauthClient, user *OauthUser, expiresIn int, scope string) *OauthAccessToken

NewOauthAccessToken creates new OauthAccessToken instance

func (*OauthAccessToken) TableName

func (at *OauthAccessToken) TableName() string

TableName specifies table name

type OauthAuthorizationCode

type OauthAuthorizationCode struct {
	MyGormModel
	ClientID    sql.NullString `sql:"index;not null"`
	UserID      sql.NullString `sql:"index;not null"`
	Client      *OauthClient
	User        *OauthUser
	Code        string         `sql:"type:varchar(40);unique;not null"`
	RedirectURI sql.NullString `sql:"type:varchar(200)"`
	ExpiresAt   time.Time      `sql:"not null"`
	Scope       string         `sql:"type:varchar(200);not null"`
}

OauthAuthorizationCode ...

func NewOauthAuthorizationCode

func NewOauthAuthorizationCode(client *OauthClient, user *OauthUser, expiresIn int, redirectURI, scope string) *OauthAuthorizationCode

NewOauthAuthorizationCode creates new OauthAuthorizationCode instance

func (*OauthAuthorizationCode) TableName

func (ac *OauthAuthorizationCode) TableName() string

TableName specifies table name

type OauthClient

type OauthClient struct {
	MyGormModel
	Key         string         `sql:"type:varchar(254);unique;not null"`
	Secret      string         `sql:"type:varchar(60);not null"`
	RedirectURI sql.NullString `sql:"type:varchar(200)"`
}

OauthClient ...

func (*OauthClient) TableName

func (c *OauthClient) TableName() string

TableName specifies table name

type OauthRefreshToken

type OauthRefreshToken struct {
	MyGormModel
	ClientID  sql.NullString `sql:"index;not null"`
	UserID    sql.NullString `sql:"index"`
	Client    *OauthClient
	User      *OauthUser
	Token     string    `sql:"type:varchar(40);unique;not null"`
	ExpiresAt time.Time `sql:"not null"`
	Scope     string    `sql:"type:varchar(200);not null"`
}

OauthRefreshToken ...

func NewOauthRefreshToken

func NewOauthRefreshToken(client *OauthClient, user *OauthUser, expiresIn int, scope string) *OauthRefreshToken

NewOauthRefreshToken creates new OauthRefreshToken instance

func (*OauthRefreshToken) TableName

func (rt *OauthRefreshToken) TableName() string

TableName specifies table name

type OauthRole

type OauthRole struct {
	TimestampModel
	ID   string `gorm:"primary_key" sql:"type:varchar(20)"`
	Name string `sql:"type:varchar(50);unique;not null"`
}

OauthRole is a one of roles user can have (currently superuser or user)

func (*OauthRole) TableName

func (r *OauthRole) TableName() string

TableName specifies table name

type OauthScope

type OauthScope struct {
	MyGormModel
	Scope       string `sql:"type:varchar(200);unique;not null"`
	Description sql.NullString
	IsDefault   bool `sql:"default:false"`
}

OauthScope ...

func (*OauthScope) TableName

func (s *OauthScope) TableName() string

TableName specifies table name

type OauthUser

type OauthUser struct {
	MyGormModel
	RoleID   sql.NullString `sql:"type:varchar(20);index;not null"`
	Role     *OauthRole
	Username string         `sql:"type:varchar(254);unique;not null"`
	Password sql.NullString `sql:"type:varchar(60)"`
}

OauthUser ...

func (*OauthUser) TableName

func (u *OauthUser) TableName() string

TableName specifies table name

type TimestampModel

type TimestampModel struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

TimestampModel ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL