models

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 24 Imported by: 5

Documentation

Index

Constants

View Source
const (
	CategoriesWithPublishedArticles = iota
	CategoriesWithoutArticles
	AllCategories
)
View Source
const (
	//Up for moving the site one up
	Up = iota
	//Down for moving the site one down
	Down
)
View Source
const (
	//OnlyAdmins conider only published
	OnlyAdmins = iota
	//NoAdmins conider no admins
	NoAdmins
	//AllUser conider all users
	AllUser
)
View Source
const (
	// OnlyPublished conider only published
	OnlyPublished = iota
	// NotPublished conider only not published
	NotPublished
	// All conider both published and not published
	All
)
View Source
const (
	VDupEmail = 1 << iota
	VDupUsername
	VPassword
)
View Source
const (
	//PasswordReset token generated for resetting passwords
	PasswordReset = iota
)

Variables

This section is empty.

Functions

func EscapeHTML

func EscapeHTML(in string) string

func MarkdownToHTML

func MarkdownToHTML(md []byte) []byte

MarkdownToHTML sanitizes and parses markdown to HTML

func NewlineToBr

func NewlineToBr(in string) string

Types

type Action

type Action struct {
	ID          string
	Title       string
	ActionURL   string
	BackLinkURL string
	WarnMsg     string
	Description string
}

Action this type is used for YES/NO actions see template/admin/action.html Title is shown in the headline ActionURL defines where the form should be sent BackLinkURL defines where to go back (if clicking on cancel) WarnMsg defines an optional warning which is shown above the description Description describes what action the user has to decide

type AdminCriteria

type AdminCriteria int

AdminCriteria specifies which type of users should be considered

type Article

type Article struct {
	ID           int
	Headline     string
	PublishedOn  NullTime
	Published    bool
	Teaser       string
	Content      string
	Slug         string
	LastModified time.Time
	Author       *User

	//duplicate category struct to support left joins with nulls
	//TODO: find a better solution
	CID   sql.NullInt64
	CName sql.NullString
}

Article represents an article

func (Article) SlugEscape

func (a Article) SlugEscape() string

SlugEscape escapes the slug for use in URLs

type ArticleDatasourceService

type ArticleDatasourceService interface {
	Create(a *Article) (int, error)
	List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)
	Count(u *User, c *Category, pc PublishedCriteria) (int, error)
	Get(articleID int, u *User, pc PublishedCriteria) (*Article, error)
	GetBySlug(slug string, u *User, pc PublishedCriteria) (*Article, error)
	Publish(a *Article) error
	Update(a *Article) error
	Delete(articleID int) error
}

ArticleDatasourceService defines an interface for CRUD operations of articles

type ArticleService

type ArticleService struct {
	Datasource ArticleDatasourceService
	AppConfig  settings.Application
}

ArticleService containing the service to access articles

func (ArticleService) Count

func (as ArticleService) Count(u *User, c *Category, pc PublishedCriteria) (int, error)

Count returns the number of articles. The publishedCriteria defines whether the published and/or unpublished articles should be considered

func (ArticleService) Create

func (as ArticleService) Create(a *Article) (int, error)

Create creates an article

func (ArticleService) Delete

func (as ArticleService) Delete(id int, u *User) error

Delete deletes an article

func (ArticleService) GetByID

func (as ArticleService) GetByID(id int, u *User, pc PublishedCriteria) (*Article, error)

GetByID get a article by the id. The publishedCriteria defines whether the published and/or unpublished articles should be considered

func (ArticleService) GetBySlug

func (as ArticleService) GetBySlug(s string, u *User, pc PublishedCriteria) (*Article, error)

GetBySlug gets a article by the slug. The publishedCriteria defines whether the published and/or unpublished articles should be considered

func (ArticleService) Index

func (ArticleService) List

func (as ArticleService) List(u *User, c *Category, p *Pagination, pc PublishedCriteria) ([]Article, error)

List returns all article by the slug. The publishedCriteria defines whether the published and/or unpublished articles should be considered

func (ArticleService) Publish

func (as ArticleService) Publish(id int, u *User) error

Publish publishes or 'unpublishes' an article

func (ArticleService) RSSFeed

func (as ArticleService) RSSFeed(p *Pagination, pc PublishedCriteria) (RSS, error)

RSSFeed receives a specified number of articles in RSS

func (ArticleService) Update

func (as ArticleService) Update(a *Article, u *User, updateSlug bool) error

Update updates an article

type Category

type Category struct {
	ID           int
	Name         string
	Slug         string
	LastModified time.Time
	Author       *User
}

func (Category) SlugEscape

func (c Category) SlugEscape() string

SlugEscape escapes the slug for use in URLs

type CategoryDatasourceService

type CategoryDatasourceService interface {
	Create(c *Category) (int, error)
	List(fc FilterCriteria) ([]Category, error)
	Count(fc FilterCriteria) (int, error)
	Get(categoryID int, fc FilterCriteria) (*Category, error)
	GetBySlug(slug string, fc FilterCriteria) (*Category, error)
	Update(c *Category) error
	Delete(categoryID int) error
}

type CategoryService

type CategoryService struct {
	Datasource CategoryDatasourceService
}

CategoryService containing the service to access categories

func (CategoryService) Count

func (cs CategoryService) Count(fc FilterCriteria) (int, error)

func (CategoryService) Create

func (cs CategoryService) Create(c *Category) (int, error)

Create creates a category

func (CategoryService) Delete

func (cs CategoryService) Delete(id int) error

Delete removes a category

func (CategoryService) GetByID

func (cs CategoryService) GetByID(id int, fc FilterCriteria) (*Category, error)

func (CategoryService) GetBySlug

func (cs CategoryService) GetBySlug(s string, fc FilterCriteria) (*Category, error)

func (CategoryService) List

func (cs CategoryService) List(fc FilterCriteria) ([]Category, error)

func (CategoryService) Update

func (cs CategoryService) Update(c *Category) error

Update updates a category

type Direction

type Direction int

Direction type to distinct if a site should be moved up or down

type File

type File struct {
	ID           int
	UniqueName   string    `json:"unique_name"`
	FullFilename string    `json:"full_name"`
	Link         string    `json:"link"`
	ContentType  string    `json:"content_type"`
	Inline       bool      `json:"inline"`
	Size         int64     `json:"size"`
	LastModified time.Time `json:"last_modified"`
	Data         []byte    `json:"-"`
	FileInfo     FileInfo
	Author       *User
}

File represents a file

type FileDatasourceService

type FileDatasourceService interface {
	Create(f *File) (int, error)
	Get(fileID int, u *User) (*File, error)
	GetByUniqueName(uniqueName string, u *User) (*File, error)
	List(u *User, p *Pagination) ([]File, error)
	Count(u *User) (int, error)
	Update(f *File) error
	Delete(fileID int) error
}

FileDatasourceService defines an interface for CRUD operations of files

type FileInfo added in v0.3.1

type FileInfo struct {
	Path      string
	Name      string
	Extension string
}

FileInfo contains Path, Name and Extension of a file. Use SplitFilename to split the information from a filename

func SplitFilename added in v0.3.1

func SplitFilename(filename string) FileInfo

type FileService

type FileService struct {
	Datasource FileDatasourceService
	Config     settings.File
}

FileService containing the service to interact with files

func (FileService) Count

func (fs FileService) Count(u *User) (int, error)

Count returns a number of files based on the filename; it the user is given and it is a non admin only files specific to this user are counted

func (FileService) Delete

func (fs FileService) Delete(fileID int, u *User) error

Delete deletes a file based on fileID; users which are not the owner are not allowed to remove files; except admins

func (FileService) GetByID

func (fs FileService) GetByID(fileID int, u *User) (*File, error)

GetByID returns the file based on the fileID; it the user is given and it is a non admin only file specific to this user is returned

func (FileService) GetByUniqueName added in v0.3.1

func (fs FileService) GetByUniqueName(uniqueName string, u *User) (*File, error)

GetByUniqueName returns the file based on the unique name; it the user is given and it is a non admin only file specific to this user is returned

func (FileService) List

func (fs FileService) List(u *User, p *Pagination) ([]File, error)

List returns a list of files based on the filename; it the user is given and it is a non admin only files specific to this user are returned

func (FileService) ToggleInline added in v0.6.1

func (fs FileService) ToggleInline(fileID int, u *User) error

func (FileService) Upload

func (fs FileService) Upload(f *File) (int, error)

Upload uploaded files will be saved at the configured file location, filename is saved in the database

type FilterCriteria

type FilterCriteria int

type IndexArticle

type IndexArticle struct {
	Year     int
	Articles []Article
}

type JSONData

type JSONData struct {
	Data interface{} `json:"data,-" xml:"data,-"`
}

JSONData represents arbritary JSON data

type Mailer

type Mailer struct {
	AppConfig *settings.Application
	Sender    mail.Sender
}
func (m Mailer) SendActivationLink(ui *UserInvite)

func (Mailer) SendPasswordChangeConfirmation

func (m Mailer) SendPasswordChangeConfirmation(u *User)
func (m Mailer) SendPasswordResetLink(u *User, t *Token)

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

NullTime reprensents a time which may not valid if time is null

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Pagination

type Pagination struct {
	Total       int
	Limit       int
	CurrentPage int
	RelURL      string
}

Pagination type is used to provide a page selector

func (Pagination) Offset

func (p Pagination) Offset() int

Offset returns the offset where to start

func (Pagination) PaginationBar

func (p Pagination) PaginationBar() template.HTML

PaginationBar returns the HTML for the pagination bar which can be embedded

type PublishedCriteria

type PublishedCriteria int

PublishedCriteria specifies which entries should be shown

type RSS

type RSS struct {
	XMLName xml.Name   `xml:"rss"`
	Version string     `xml:"version,attr"`
	Channel RSSChannel `xml:"channel"`
}

type RSSChannel

type RSSChannel struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description string `xml:"description"`
	Language    string `xml:"language"`

	Items []RSSItem `xml:"item"`
}

type RSSItem

type RSSItem struct {
	GUID        string  `xml:"guid"`
	Author      string  `xml:"author"`
	Title       string  `xml:"title"`
	Link        string  `xml:"link"`
	Description string  `xml:"description"`
	PubDate     RSSTime `xml:"pubDate"`
}

type RSSTime

type RSSTime time.Time

func (RSSTime) MarshalXML

func (r RSSTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type SQLiteArticleDatasource

type SQLiteArticleDatasource struct {
	SQLConn *sql.DB
}

SQLiteArticleDatasource providing an implementation of ArticleDatasourceService for SQLite

func (SQLiteArticleDatasource) Count

Count returns the number of article found; if the user is not nil the number of articles for this explcit user is returned the PublishedCritera specifies which articles should be considered

func (SQLiteArticleDatasource) Create

func (rdb SQLiteArticleDatasource) Create(a *Article) (int, error)

Create creates an article

func (SQLiteArticleDatasource) Delete

func (rdb SQLiteArticleDatasource) Delete(articleID int) error

Delete deletes the article specified by the articleID

func (SQLiteArticleDatasource) Get

func (rdb SQLiteArticleDatasource) Get(articleID int, u *User, pc PublishedCriteria) (*Article, error)

Get returns a article by its id; if the user is not nil the article for this explcit user is returned the PublishedCritera specifies which articles should be considered

func (SQLiteArticleDatasource) GetBySlug

func (rdb SQLiteArticleDatasource) GetBySlug(slug string, u *User, pc PublishedCriteria) (*Article, error)

GetBySlug returns a article by its slug; if the user is not nil the article for this explcit user is returned the PublishedCritera specifies which articles should be considered

func (SQLiteArticleDatasource) List

List returns a slice of articles; if the user is not nil the number of articles for this explcit user is returned the PublishedCritera specifies which articles should be considered

func (SQLiteArticleDatasource) Publish

func (rdb SQLiteArticleDatasource) Publish(a *Article) error

Publish checks if the article is published or not - switches the appropriate status

func (SQLiteArticleDatasource) Update

func (rdb SQLiteArticleDatasource) Update(a *Article) error

Update updates an aricle

type SQLiteCategoryDatasource

type SQLiteCategoryDatasource struct {
	SQLConn *sql.DB
}

SQLiteArticleDatasource providing an implementation of ArticleDatasourceService for SQLite

func (SQLiteCategoryDatasource) Count

func (SQLiteCategoryDatasource) Create

func (rdb SQLiteCategoryDatasource) Create(c *Category) (int, error)

func (SQLiteCategoryDatasource) Delete

func (rdb SQLiteCategoryDatasource) Delete(categoryID int) error

func (SQLiteCategoryDatasource) Get

func (rdb SQLiteCategoryDatasource) Get(categoryID int, fc FilterCriteria) (*Category, error)

func (SQLiteCategoryDatasource) GetBySlug

func (rdb SQLiteCategoryDatasource) GetBySlug(slug string, fc FilterCriteria) (*Category, error)

func (SQLiteCategoryDatasource) List

func (SQLiteCategoryDatasource) Update

func (rdb SQLiteCategoryDatasource) Update(c *Category) error

type SQLiteFileDatasource

type SQLiteFileDatasource struct {
	SQLConn *sql.DB
}

SQLiteFileDatasource providing an implementation of FileDatasourceService using MariaDB

func (SQLiteFileDatasource) Count

func (rdb SQLiteFileDatasource) Count(u *User) (int, error)

Count returns a number of files based on the filename; it the user is given and it is a non admin only files specific to this user are counted

func (SQLiteFileDatasource) Create

func (rdb SQLiteFileDatasource) Create(f *File) (int, error)

Create inserts some file meta information into the database

func (SQLiteFileDatasource) Delete

func (rdb SQLiteFileDatasource) Delete(fileID int) error

Delete deletes a file based on fileID; users which are not the owner are not allowed to remove files; except admins

func (SQLiteFileDatasource) Get

func (rdb SQLiteFileDatasource) Get(fileID int, u *User) (*File, error)

Get returns the file based on the filename; it the user is given and it is a non admin only file specific to this user is returned

func (SQLiteFileDatasource) GetByUniqueName added in v0.3.1

func (rdb SQLiteFileDatasource) GetByUniqueName(uniqueName string, u *User) (*File, error)

GetByFilename returns the file based on the filename; it the user is given and it is a non admin only file specific to this user is returned

func (SQLiteFileDatasource) List

func (rdb SQLiteFileDatasource) List(u *User, p *Pagination) ([]File, error)

List returns a list of files based on the filename; it the user is given and it is a non admin only files specific to this user are returned

func (SQLiteFileDatasource) Update added in v0.6.1

func (rdb SQLiteFileDatasource) Update(f *File) error

type SQLiteSiteDatasource

type SQLiteSiteDatasource struct {
	SQLConn *sql.DB
}

SQLiteSiteDatasource providing an implementation of SiteDatasourceService for sqlite

func (SQLiteSiteDatasource) Count

Count returns the amount of sites

func (SQLiteSiteDatasource) Create

func (rdb SQLiteSiteDatasource) Create(s *Site) (int, error)

Create creates a site

func (SQLiteSiteDatasource) Delete

func (rdb SQLiteSiteDatasource) Delete(s *Site) error

Delete deletes a site and updates the order numbers

func (SQLiteSiteDatasource) Get

func (rdb SQLiteSiteDatasource) Get(siteID int, pc PublishedCriteria) (*Site, error)

Get returns a site based on the site id

func (rdb SQLiteSiteDatasource) GetByLink(link string, pc PublishedCriteria) (*Site, error)

GetByLink returns a site based on the provided link

func (SQLiteSiteDatasource) List

List returns a array of sites

func (SQLiteSiteDatasource) Max

func (rdb SQLiteSiteDatasource) Max() (int, error)

Max returns the maximum order number

func (SQLiteSiteDatasource) Order

func (rdb SQLiteSiteDatasource) Order(id int, d Direction) error

Order moves a site up or down

func (SQLiteSiteDatasource) Publish

func (rdb SQLiteSiteDatasource) Publish(s *Site) error

Publish publishes or unpublishes a site

func (SQLiteSiteDatasource) Update

func (rdb SQLiteSiteDatasource) Update(s *Site) error

Update updates a site

type SQLiteTokenDatasource

type SQLiteTokenDatasource struct {
	SQLConn *sql.DB
}

SQLiteTokenDatasource providing an implementation of TokenDatasourceService using MariaDB

func (SQLiteTokenDatasource) Create

func (rdb SQLiteTokenDatasource) Create(t *Token) (int, error)

Create creates a new token

func (SQLiteTokenDatasource) Get

func (rdb SQLiteTokenDatasource) Get(hash string, tt TokenType) (*Token, error)

Get gets a token based on the hash and the token type

func (SQLiteTokenDatasource) ListByUser added in v0.5.3

func (rdb SQLiteTokenDatasource) ListByUser(userID int, tt TokenType) ([]Token, error)

ListByUser receives all tokens based on the user id and the token type ordered by requested

func (SQLiteTokenDatasource) Remove

func (rdb SQLiteTokenDatasource) Remove(hash string, tt TokenType) error

Remove removes a token based on the hash

type SQLiteUserDatasource

type SQLiteUserDatasource struct {
	SQLConn *sql.DB
}

SQLiteUserDatasource providing an implementation of UserDatasourceService using SQLite

func (SQLiteUserDatasource) Count

func (rdb SQLiteUserDatasource) Count(ac AdminCriteria) (int, error)

Count retuns the amount of users matches the AdminCriteria

func (SQLiteUserDatasource) Create

func (rdb SQLiteUserDatasource) Create(u *User) (int, error)

Create creates an new user

func (SQLiteUserDatasource) Get

func (rdb SQLiteUserDatasource) Get(userID int) (*User, error)

Get gets an user by his userID

func (SQLiteUserDatasource) GetByMail

func (rdb SQLiteUserDatasource) GetByMail(mail string) (*User, error)

GetByMail gets an user by his mail, includes the password and salt

func (SQLiteUserDatasource) GetByUsername

func (rdb SQLiteUserDatasource) GetByUsername(username string) (*User, error)

GetByUsername gets an user by his username, includes the password and salt

func (SQLiteUserDatasource) List

func (rdb SQLiteUserDatasource) List(p *Pagination) ([]User, error)

List returns a list of user

func (SQLiteUserDatasource) Remove

func (rdb SQLiteUserDatasource) Remove(userID int) error

Removes an user

func (SQLiteUserDatasource) Update

func (rdb SQLiteUserDatasource) Update(u *User, changePassword bool) error

Update updates an user

type SQLiteUserInviteDatasource

type SQLiteUserInviteDatasource struct {
	SQLConn *sql.DB
}

SQLiteUserInviteDatasource

func (SQLiteUserInviteDatasource) Count

func (rdb SQLiteUserInviteDatasource) Count() (int, error)

Count retuns the amount of users invitations

func (SQLiteUserInviteDatasource) Create

func (rdb SQLiteUserInviteDatasource) Create(ui *UserInvite) (int, error)

Create creates an new user invitation

func (SQLiteUserInviteDatasource) Get

func (rdb SQLiteUserInviteDatasource) Get(inviteID int) (*UserInvite, error)

func (SQLiteUserInviteDatasource) GetByHash

func (rdb SQLiteUserInviteDatasource) GetByHash(hash string) (*UserInvite, error)

func (SQLiteUserInviteDatasource) List

func (SQLiteUserInviteDatasource) Remove

func (rdb SQLiteUserInviteDatasource) Remove(inviteID int) error

Removes an user invitation

func (SQLiteUserInviteDatasource) Update

type Site

type Site struct {
	ID           int
	Title        string
	Link         string
	Section      string
	Content      string
	Published    bool
	PublishedOn  NullTime
	LastModified time.Time
	OrderNo      int
	Author       *User
}

Site represents a site

func (Site) LinkEscape

func (s Site) LinkEscape() string

LinkEscape escapes a link for safe use in URLs

type SiteDatasourceService

type SiteDatasourceService interface {
	Create(s *Site) (int, error)
	List(pc PublishedCriteria, p *Pagination) ([]Site, error)
	Get(siteID int, pc PublishedCriteria) (*Site, error)
	GetByLink(link string, pc PublishedCriteria) (*Site, error)
	Publish(s *Site) error
	Update(s *Site) error
	Delete(s *Site) error
	Order(siteID int, dir Direction) error
	Max() (int, error)
	Count(pc PublishedCriteria) (int, error)
}

SiteDatasourceService defines an interface for CRUD operations on sites

type SiteService

type SiteService struct {
	Datasource SiteDatasourceService
}

SiteService containing the service to access site

func (SiteService) Count

func (ss SiteService) Count(pc PublishedCriteria) (int, error)

Count returns the number of sites

func (SiteService) Create

func (ss SiteService) Create(s *Site) (int, error)

Create creates a site

func (SiteService) Delete

func (ss SiteService) Delete(siteID int) error

Delete deletes a site

func (SiteService) GetByID

func (ss SiteService) GetByID(siteID int, pc PublishedCriteria) (*Site, error)

GetByID Get a site by the id.

func (ss SiteService) GetByLink(link string, pc PublishedCriteria) (*Site, error)

GetByLink Get a site by the link.

func (SiteService) List

func (ss SiteService) List(pc PublishedCriteria, p *Pagination) ([]Site, error)

List returns all sites

func (SiteService) Order

func (ss SiteService) Order(siteID int, dir Direction) error

Order reorder the site

func (SiteService) Publish

func (ss SiteService) Publish(siteID int) error

Publish switches the publish state of the site

func (SiteService) Update

func (ss SiteService) Update(s *Site) error

Update updates a site

type Token

type Token struct {
	ID          int
	Hash        string
	Type        TokenType
	RequestedAt time.Time

	Author *User
}

Token represents a token

type TokenDatasourceService

type TokenDatasourceService interface {
	Create(t *Token) (int, error)
	Get(hash string, tt TokenType) (*Token, error)
	ListByUser(userID int, tt TokenType) ([]Token, error)
	Remove(hash string, tt TokenType) error
}

TokenDatasourceService defines an interface for CRUD operations for tokens

type TokenService

type TokenService struct {
	Datasource TokenDatasourceService
}

TokenService containing the service to access tokens

func (TokenService) Create

func (ts TokenService) Create(t *Token) error

Create creates a new token

func (TokenService) Get

func (ts TokenService) Get(hash string, tt TokenType, expireAfter time.Duration) (*Token, error)

Get token for a defined token type expires after a defined time Expired token will be removed

func (TokenService) RateLimit added in v0.5.3

func (ts TokenService) RateLimit(userID int, tt TokenType) error

RateLimit returns an error if a token is requested greater three times in a time span of 15 minutes

func (TokenService) Remove

func (ts TokenService) Remove(hash string, tt TokenType) error

Remove removes a token

type TokenType

type TokenType int

TokenType specifies the type where token can be used

func (*TokenType) Scan

func (tt *TokenType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (TokenType) String

func (tt TokenType) String() string

func (TokenType) Value

func (tt TokenType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type User

type User struct {
	ID            int
	Username      string
	Email         string
	DisplayName   string
	Password      []byte
	PlainPassword []byte
	Salt          []byte
	LastModified  time.Time
	Active        bool
	IsAdmin       bool
}

User represents a user

type UserDatasourceService

type UserDatasourceService interface {
	Create(u *User) (int, error)
	List(p *Pagination) ([]User, error)
	Get(userID int) (*User, error)
	Update(u *User, changePassword bool) error
	Count(ac AdminCriteria) (int, error)
	GetByMail(mail string) (*User, error)
	GetByUsername(username string) (*User, error)
	Remove(userID int) error
}

UserDatasourceService defines an interface for CRUD operations for users

type UserInterceptor

type UserInterceptor interface {
	PreCreate(user *User) error
	PostCreate(user *User) error
	PreUpdate(oldUser *User, user *User) error
	PostUpdate(oldUser *User, user *User) error
	PreRemove(user *User) error
	PostRemove(user *User) error
}

UserInterceptor will be executed before and after updating/creating users

type UserInvite

type UserInvite struct {
	ID          int
	Hash        string
	Username    string
	Email       string
	DisplayName string
	CreatedAt   time.Time
	IsAdmin     bool

	CreatedBy *User
}

User represents a user

func (UserInvite) Copy

func (ui UserInvite) Copy() *User

type UserInviteDatasourceService

type UserInviteDatasourceService interface {
	List() ([]UserInvite, error)
	Get(inviteID int) (*UserInvite, error)
	GetByHash(hash string) (*UserInvite, error)
	Create(ui *UserInvite) (int, error)
	Update(ui *UserInvite) error
	Remove(inviteID int) error
}

UserInviteDatasourceService defines an interface for CRUD operations for users

type UserInviteService

type UserInviteService struct {
	Datasource  UserInviteDatasourceService
	UserService UserService
	MailService mail.Service
}

UserInviteService

func (UserInviteService) Create

func (uis UserInviteService) Create(ui *UserInvite) (int, error)

func (UserInviteService) Get

func (uis UserInviteService) Get(inviteID int) (*UserInvite, error)

func (UserInviteService) GetByHash

func (uis UserInviteService) GetByHash(hash string) (*UserInvite, error)

func (UserInviteService) List

func (uis UserInviteService) List() ([]UserInvite, error)

func (UserInviteService) Remove

func (uis UserInviteService) Remove(inviteID int) error

func (UserInviteService) Update

func (uis UserInviteService) Update(ui *UserInvite) error

type UserService

type UserService struct {
	Datasource      UserDatasourceService
	Config          settings.User
	UserInterceptor UserInterceptor
}

UserService containing the service to access users

func (UserService) Authenticate

func (us UserService) Authenticate(u *User, loginMethod settings.LoginMethod) (*User, error)

Authenticate authenticates the user by the given login method (email or username) if the user was found but the password is wrong the found user and an error will be returned

func (UserService) Count

func (us UserService) Count(a AdminCriteria) (int, error)

Count returns the amount of users

func (UserService) Create

func (us UserService) Create(u *User) (int, error)

Create creates the user If an UserInterceptor is available the action PreCreate is executed before creating and PostCreate after creating the user

func (UserService) GetByID

func (us UserService) GetByID(userID int) (*User, error)

GetByID gets the user based on the given id; will not contain the user password

func (UserService) GetByMail

func (us UserService) GetByMail(mail string) (*User, error)

GetByMail gets the user based on the given mail; will contain the user password

func (UserService) GetByUsername

func (us UserService) GetByUsername(username string) (*User, error)

GetByUsername gets the user based on the given username; will contain the user password

func (UserService) List

func (us UserService) List(p *Pagination) ([]User, error)

List returns a list of users. Limits the amount based on the defined pagination

func (UserService) OneAdmin added in v0.2.4

func (us UserService) OneAdmin() (bool, error)

OneAdmin returns true if there is only one admin

func (UserService) Remove

func (us UserService) Remove(u *User) error

Remove removes the user returns an error if no administrator would remain

func (UserService) Update

func (us UserService) Update(u *User, changePassword bool) error

Update updates the user If an UserInterceptor is available the action PreUpdate is executed before updating and PostUpdate after updating the user

type Validations

type Validations int

type XMLData

type XMLData struct {
	Data      interface{} `xml:"data,-"`
	HexEncode bool        `xml:"-"`
}

XMLData represents arbritary XML data

Jump to

Keyboard shortcuts

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