repository

package
v0.0.0-...-37076da Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateSession

func NewCreateSession(db database.Database) auth.CreateSessionRepository

NewCreateSession return a auth.CreateSessionRepository implementation

func NewDeleteSession

func NewDeleteSession(db database.Database) auth.DeleteSessionRepository

NewDeleteSession will return auth.DeleteSessionRepository

func NewGetLoggedUser

func NewGetLoggedUser(db database.Database) auth.GetLoggedUsr

func NewGetSingleSession

func NewGetSingleSession(db database.Database) auth.GetSingleSessionRepository

NewGetSginelSession returns an auth.GetSingleSessionRepository implementation

func NewUpdateSession

func NewUpdateSession(db database.Database) auth.UpdateSessionRepository

NewUpdateSession returns an auth.UpdateSessionRepository implementation

Types

type SessionModel

type SessionModel struct {
	SessID       string    `gorm:"primary_key;column:session_id;type:uuid;default:uuid_generate_v4();index:idx_sess_id"`
	UserID       string    `gorm:"column:usr_id;type:uuid;unique;index:idx_usr_id;not null"`
	Expiration   time.Time `gorm:"column:expiration;type:timestamp with time zone;not null"`
	AccessToken  string    `gorm:"column:access_token;type:text;not null"`
	RefreshToken string    `gorm:"column:refresh_token;type:text;not null"`
}

SessionModel represents how a session is stored in the database

func (*SessionModel) AsDomain

func (sm *SessionModel) AsDomain() auth.Session

AsDomain will return a SessionModel as auth.Session

func (*SessionModel) BeforeCreate

func (sm *SessionModel) BeforeCreate(*gorm.DB) error

BeforeCreate is a hook to set the expiration field

Read more about GORM hooks:

https://gorm.io/docs/hooks.html#Creating-an-object

func (*SessionModel) TableName

func (sm *SessionModel) TableName() string

TableName overrides the table name used by SessionModel to `sessions`

Read more about GORM conventions:

https://gorm.io/docs/conventions.html#TableName

type UserModel

type UserModel struct {
	ID        string    `gorm:"primary_key;column:usr_id;type:uuid;default:uuid_generate_v4();index:idx_usr_id"`
	Email     string    `gorm:"column:usr_email;unique;type:varchar(255);"`
	Type      string    `gorm:"column:usr_scope;type:varchar(64);default:student"`
	CreatedAt time.Time `gorm:"column:usr_created_at;type:timestamp with time zone;default:now()"`
	UpdatedAt time.Time `gorm:"column:usr_updated_at;type:timestamp with time zone;default:now()"`
}

UserModel represents how a student is stored in the database.

func (UserModel) TableName

func (UserModel) TableName() string

TableName overrides the table name used by UserModel to `users`

Read more about GORM conventions:

https://gorm.io/docs/conventions.html#TableName

Jump to

Keyboard shortcuts

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