views

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBUserToDetailedUser added in v0.7.1

func DBUserToDetailedUser(dbUser user.User, store *user.Store) user.DetailedUser

DBUserToDetailedUser handles all the little details for the users front end

func DBUsersToUsersTemplateFormat added in v0.7.1

func DBUsersToUsersTemplateFormat(dbUsers []user.User) []user.StrippedUser

DBUsersToUsersTemplateFormat converts from the DB layer type to the user template type

Types

type Config

type Config struct {
	Version           string
	Debug             bool
	Address           string
	DatabaseURL       string
	BaseDomainName    string
	DomainName        string
	LogoutEndpoint    string
	SessionCookieName string
	Mail              SMTPConfig
	Security          SecurityConfig
}

Config the global web-auth configuration

type Context

type Context struct {
	// TitleText is used for sending pages to the user with custom titles
	TitleText string
	// Message is used for sending a message back to the user trying to log in, might decide to move later as it may not be needed
	Message string
	// MsgType is the bulma.io class used to indicate what should be displayed
	MsgType string
	// Callback is the address to redirect the user to
	Callback string
	// User is the stored logged-in user
	User user.User
	// Version is the version that is running
	Version string
	Assumed bool
	// contains filtered or unexported fields
}

Context is a struct that is applied to the templates.

type InternalContext added in v0.7.1

type InternalContext struct {
	TitleText string
	Message   string
	MesType   string
}

type InternalTemplate

type InternalTemplate struct {
	UserID    int
	Nickname  string
	LastLogin string
	CountAll  user.CountUsers
	TemplateHelper
}

InternalTemplate represents the context for the internal template

type JWTClaims

type JWTClaims struct {
	UserID      int      `json:"id"`
	Permissions []string `json:"perms"`
	jwt.RegisteredClaims
}

JWTClaims represents basic identifiable/useful claims

type ManageAPITemplate added in v0.7.1

type ManageAPITemplate struct {
	Tokens   []api.Token
	AddedJWT string
	TemplateHelper
}

ManageAPITemplate returns the data to the front end

type Notification added in v0.7.1

type Notification struct {
	Title   string
	MsgType string
	Message string
}

Notification template for messages

type PermissionTemplate added in v0.7.1

type PermissionTemplate struct {
	Permission user.PermissionTemplate
	TemplateHelper
}

PermissionTemplate is for the permission front end

type PermissionsTemplate added in v0.7.1

type PermissionsTemplate struct {
	Permissions []permission.Permission
	TemplateHelper
}

PermissionsTemplate is for the permissions front end

type RoleTemplate added in v0.7.1

type RoleTemplate struct {
	Role                 user.RoleTemplate
	PermissionsNotInRole []permission.Permission
	UsersNotInRole       []user.User
	TemplateHelper
}

RoleTemplate is for the role front end

type RolesTemplate added in v0.7.1

type RolesTemplate struct {
	Roles []role.Role
	TemplateHelper
}

RolesTemplate is for the roles front end

type SMTPConfig

type SMTPConfig struct {
	Host       string
	Username   string
	Password   string
	Port       int
	DomainName string
}

SMTPConfig stores the SMTP Mailer configuration

type SecurityConfig

type SecurityConfig struct {
	EncryptionKey     string
	AuthenticationKey string
	SigningKey        string
}

SecurityConfig stores the security configuration

type SettingsTemplate added in v0.7.1

type SettingsTemplate struct {
	User      user.User
	LastLogin string
	Gravatar  string
	TemplateHelper
}

SettingsTemplate is for the settings front end

type Sort added in v0.7.1

type Sort struct {
	Pages      int
	Size       int
	PageNumber int
	Column     string
	Direction  string
	Search     string
	Enabled    string
	Deleted    string
}

Sort is the parameters for how to sort a users request

type TemplateHelper added in v0.7.1

type TemplateHelper struct {
	UserPermissions []permission.Permission
	ActivePage      string
	Assumed         bool
}

type UserSignup

type UserSignup struct {
	Firstname       string `db:"first_name" schema:"firstname" validate:"required,gte=3"`
	Lastname        string `db:"last_name" schema:"lastname" validate:"required,gte=3"`
	Email           string `db:"email" schema:"email" validate:"required,email"`
	Password        string `db:"password" schema:"password" validate:"required,gte=8"`
	ConfirmPassword string `schema:"confirmpassword" validate:"required,eqfield=Password,gte=8"`
}

UserSignup represents the HTML form

type UserTemplate added in v0.7.1

type UserTemplate struct {
	User user.DetailedUser
	TemplateHelper
}

UserTemplate is for the user front end

type UsersTemplate

type UsersTemplate struct {
	Users    []user.StrippedUser
	CurPage  int
	NextPage int
	PrevPage int
	LastPage int
	Sort     Sort
	TemplateHelper
}

UsersTemplate represents the context for the user template

type Views

type Views struct {
	Mailer *mail.Mailer
	// contains filtered or unexported fields
}

Views encapsulates our view dependencies

func New

func New(conf *Config, host string) *Views

New initialises connections, templates, and cookies

func (*Views) AssumeUserFunc added in v0.7.1

func (v *Views) AssumeUserFunc(c echo.Context) error

func (*Views) ChangePasswordFunc added in v0.7.1

func (v *Views) ChangePasswordFunc(c echo.Context) error

ChangePasswordFunc handles the password change from a user

func (*Views) CustomHTTPErrorHandler added in v0.7.1

func (v *Views) CustomHTTPErrorHandler(err error, c echo.Context)

func (*Views) Error404 added in v0.7.1

func (v *Views) Error404(c echo.Context) error

func (*Views) ForgotFunc

func (v *Views) ForgotFunc(c echo.Context) error

ForgotFunc handles sending a reset email

func (*Views) IndexFunc

func (v *Views) IndexFunc(c echo.Context) error

IndexFunc handles the index page.

func (*Views) InternalFunc

func (v *Views) InternalFunc(c echo.Context) error

InternalFunc handles a request to the internal template

func (*Views) LoginFunc

func (v *Views) LoginFunc(c echo.Context) error

LoginFunc implements the login functionality, will add a cookie to the cookie store for managing authentication

func (*Views) LogoutFunc

func (v *Views) LogoutFunc(c echo.Context) error

LogoutFunc Implements the logout functionality. Will delete the session information from the cookie store

func (*Views) ManageAPIFunc added in v0.7.1

func (v *Views) ManageAPIFunc(c echo.Context) error

ManageAPIFunc is the main home page for API management

func (*Views) PermissionAddFunc added in v0.7.1

func (v *Views) PermissionAddFunc(c echo.Context) error

PermissionAddFunc handles an add permission request

func (*Views) PermissionDeleteFunc added in v0.7.1

func (v *Views) PermissionDeleteFunc(c echo.Context) error

PermissionDeleteFunc handles a delete permission request

func (*Views) PermissionEditFunc added in v0.7.1

func (v *Views) PermissionEditFunc(c echo.Context) error

PermissionEditFunc handles an edit permission request

func (*Views) PermissionFunc added in v0.7.1

func (v *Views) PermissionFunc(c echo.Context) error

PermissionFunc handles a permission request

func (*Views) PermissionsFunc added in v0.7.1

func (v *Views) PermissionsFunc(c echo.Context) error

PermissionsFunc handles a permissions request

func (*Views) ReleaseUserFunc added in v0.7.1

func (v *Views) ReleaseUserFunc(c echo.Context) error

func (*Views) RequirePermission added in v0.7.1

func (v *Views) RequirePermission(p permissions.Permissions) echo.MiddlewareFunc

func (*Views) RequiresLogin

func (v *Views) RequiresLogin(next echo.HandlerFunc) echo.HandlerFunc

RequiresLogin is a middleware which will be used for each httpHandler to check if there is any active session

func (*Views) RequiresLoginJSON added in v0.7.1

func (v *Views) RequiresLoginJSON(next echo.HandlerFunc) echo.HandlerFunc

RequiresLoginJSON is a middleware which is used for each httpHandler to check if there is any active session and returns json if not

func (*Views) ResetURLFunc added in v0.7.1

func (v *Views) ResetURLFunc(c echo.Context) error

func (*Views) ResetUserPasswordFunc added in v0.7.1

func (v *Views) ResetUserPasswordFunc(c echo.Context) error

func (*Views) RoleAddFunc added in v0.7.1

func (v *Views) RoleAddFunc(c echo.Context) error

RoleAddFunc handles a role add request

func (*Views) RoleAddPermissionFunc added in v0.7.1

func (v *Views) RoleAddPermissionFunc(c echo.Context) error

RoleAddPermissionFunc handles a rolePermission add request

func (*Views) RoleAddUserFunc added in v0.7.1

func (v *Views) RoleAddUserFunc(c echo.Context) error

RoleAddUserFunc handles a roleUser add request

func (*Views) RoleDeleteFunc added in v0.7.1

func (v *Views) RoleDeleteFunc(c echo.Context) error

RoleDeleteFunc handles a role delete request

func (*Views) RoleEditFunc added in v0.7.1

func (v *Views) RoleEditFunc(c echo.Context) error

RoleEditFunc handles a role edit request

func (*Views) RoleFunc added in v0.7.1

func (v *Views) RoleFunc(c echo.Context) error

RoleFunc handles a role request

func (*Views) RoleRemovePermissionFunc added in v0.7.1

func (v *Views) RoleRemovePermissionFunc(c echo.Context) error

RoleRemovePermissionFunc handles a rolePermission remove request

func (*Views) RoleRemoveUserFunc added in v0.7.1

func (v *Views) RoleRemoveUserFunc(c echo.Context) error

RoleRemoveUserFunc handles a roleUser remove request

func (*Views) RolesFunc added in v0.7.1

func (v *Views) RolesFunc(c echo.Context) error

RolesFunc handles a roles request

func (*Views) SetTokenHandler

func (v *Views) SetTokenHandler(c echo.Context) error

SetTokenHandler sets a valid JWT in a cookie instead of returning a string

func (*Views) SettingsFunc added in v0.7.1

func (v *Views) SettingsFunc(c echo.Context) error

SettingsFunc handles a request to the internal template

func (*Views) SignUpFunc

func (v *Views) SignUpFunc(c echo.Context) error

SignUpFunc will enable new users to sign up to our service

func (*Views) TestAPITokenFunc added in v0.7.1

func (v *Views) TestAPITokenFunc(c echo.Context) error

TestAPITokenFunc returns a JSON object if the JWT in the Authorization header is valid.

func (*Views) TokenAddFunc added in v0.7.1

func (v *Views) TokenAddFunc(c echo.Context) error

TokenAddFunc adds a token to be used by the user

func (*Views) TokenDeleteFunc added in v0.7.1

func (v *Views) TokenDeleteFunc(c echo.Context) error

TokenDeleteFunc deletes a token

func (*Views) UserAddFunc added in v0.7.1

func (v *Views) UserAddFunc(c echo.Context) error

UserAddFunc handles an add user request

func (*Views) UserDeleteFunc added in v0.7.1

func (v *Views) UserDeleteFunc(c echo.Context) error

UserDeleteFunc handles an delete user request

func (*Views) UserEditFunc added in v0.7.1

func (v *Views) UserEditFunc(c echo.Context) error

UserEditFunc handles an edit user request

func (*Views) UserFunc

func (v *Views) UserFunc(c echo.Context) error

UserFunc handles a users request

func (*Views) UserToggleEnabledFunc added in v0.7.1

func (v *Views) UserToggleEnabledFunc(c echo.Context) error

UserToggleEnabledFunc handles an toggle enable user request

func (*Views) UsersFunc

func (v *Views) UsersFunc(c echo.Context) error

UsersFunc handles a users request

func (*Views) ValidateToken

func (v *Views) ValidateToken(token string) (bool, *JWTClaims, error)

ValidateToken will validate the token

Jump to

Keyboard shortcuts

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