Documentation ¶
Index ¶
- Variables
- func RespCreateBase(model string) (int, interface{})
- func RespCreated(i interface{}, model string) (int, interface{})
- func RespDeleted(model string) (int, interface{})
- func RespExecuted(model string) (int, interface{})
- func RespSelected(i interface{}, model string) (int, interface{})
- func RespUpdated(model string) (int, interface{})
- type APIResponse
- type Access
- type AccessList
- type AccessToken
- type Avatar
- type Campaign
- type CodeRequest
- type ContentText
- type DisplayContent
- type JWTToken
- type LinkToken
- type MID
- type MailBase
- type MailCode
- type MailContactAt
- type Modified
- type MultiLang
- type PValidate
- type Permission
- type Profile
- type RefreshToken
- type SimpleID
- type User
Constants ¶
This section is empty.
Variables ¶
var AccessConfig = middleware.JWTConfig{ Claims: &AccessToken{}, ContextKey: "token", SigningKey: []byte(os.Getenv("JWT_SECRET")), }
AccessConfig can with echo for middleware.JWTWithConfig(vmod.AccessConfig) to handling access controll The token is reachable with c.Get("token")
var RefreshConfig = middleware.JWTConfig{ Claims: &RefreshToken{}, ContextKey: "token", SigningKey: []byte(os.Getenv("JWT_SECRET")), }
RefreshConfig can with echo for middleware.JWTWithConfig(vmod.AccessConfig) to handling access controll The token is reachable with c.Get("token")
Functions ¶
func RespCreateBase ¶ added in v0.1.1
RespCreateBase creates the created response without payload
func RespCreated ¶ added in v0.1.1
RespCreated creates the created response
func RespDeleted ¶ added in v0.1.12
RespDeleted creates the updated response
func RespExecuted ¶ added in v0.1.1
RespExecuted creates the execution response for handling for example sending emails.
func RespSelected ¶ added in v0.1.1
RespSelected creates the selected response
func RespUpdated ¶ added in v0.1.1
RespUpdated creates the updated response
Types ¶
type APIResponse ¶ added in v0.1.1
type APIResponse struct { Message string `json:"message"` Model string `json:"model"` Payload interface{} `json:"payload,omitempty"` }
APIResponse type that will response in success cases
type Access ¶
type Access struct { Role string `json:"role" bson:"role"` Created int64 `json:"created" bson:"created"` }
Access represents access to an model.
type AccessList ¶ added in v0.1.0
type AccessList []Access
AccessList list of access model
func (AccessList) Map ¶ added in v0.1.0
func (a AccessList) Map() map[string]string
Map converts an access list into map
type AccessToken ¶ added in v0.1.0
type AccessToken struct { User User `json:"user"` jwt.StandardClaims }
AccessToken represents the access token contained in JWTToken
type Avatar ¶
type Avatar struct { URL string `bson:"url" json:"url"` Type string `bson:"type" json:"type"` Updated int64 `bson:"updated" json:"updated" validate:"required"` Created int64 `bson:"created" json:"created" validate:"required"` }
Avatar represents the avatar for an User
type Campaign ¶
type Campaign struct { ID string `bson:"_id" json:"id" validate:"required"` CiviID int `bson:"civi_id" json:"civi_id" validate:"required"` Name string `bson:"name" json:"name" validate:"required"` Description string `bson:"name" json:"description" validate:"required"` Tags []string `bson:"tags" json:"tags" validate:"required"` Type string `bson:"type" json:"type" validate:"required"` Modified Modified `bson:"modified" json:"modified" validate:"required"` }
Campaign represents a default campaign model
type CodeRequest ¶ added in v0.1.1
CodeRequest used for handling LinkToken code.
type ContentText ¶ added in v0.1.13
type DisplayContent ¶ added in v0.1.13
type DisplayContent struct { Language []string `bson:"language" json:"language"` Keys []string `bson:"keys" json:"keys"` Translation map[string]ContentText `bson:"translation" json:"translation"` Default string `bson:"default" json:"default"` }
func (*DisplayContent) Validate ¶ added in v0.1.13
func (dc *DisplayContent) Validate() *DisplayContent
type JWTToken ¶ added in v0.1.0
type JWTToken struct { AccessToken string `json:"access_token" bson:"access_token"` RefreshToken string `json:"refresh_token" bson:"refresh_token"` TokenType string `json:"token_type" bson:"token_type"` ExpiresAt int64 `json:"expires_at" bson:"expires_at"` Scope string `json:"scope" bson:"scope"` }
JWTToken represents the all access and refresh tokens
type LinkToken ¶ added in v0.1.0
type LinkToken struct { ID string `bson:"_id" json:"token_id"` Code string `bson:"code" json:"code"` Tcase string `json:"t_case"` Scope string `json:"scope"` Expired int64 `json:"expired"` Created int64 `json:"created"` ModelID string `json:"model_id" bson:"model_id"` }
LinkToken is used for handling link with token
type MailBase ¶ added in v0.1.1
type MailBase struct { To string `json:"to" bson:"to"` JobCase string `json:"job_case"` JobScope string `json:"job_scope"` Country string `json:"country"` }
MailBase base model for request mail-backend via nats
type MailContactAt ¶ added in v0.1.18
type Modified ¶
type Modified struct { Updated int64 `json:"updated" bson:"updated,omitempty"` Created int64 `json:"created" bson:"created,omitempty"` }
Modified represents update and create timestamp for all models.
func NewModified ¶ added in v0.0.8
func NewModified() *Modified
NewModified initial Modified model, cTime is the current time Unix format.
type MultiLang ¶ added in v0.1.13
type PValidate ¶ added in v0.1.0
PValidate used for controller permission handling
func (*PValidate) Restricted ¶ added in v0.1.0
func (pVal *PValidate) Restricted(next echo.HandlerFunc) echo.HandlerFunc
Restricted middleware function for handling Access
type Permission ¶
type Permission map[string]AccessList
Permission represents role to an access
func NewPermission ¶
func NewPermission(app string, role string) *Permission
NewPermission map role to []Access(modelID, created) and initial Permission.
func (*Permission) Add ¶
func (p *Permission) Add(app string, role string) *Permission
Add Access(modelID created) to role.
func (*Permission) Delete ¶
func (p *Permission) Delete(role string, modelID string) *Permission
Delete Access from role. If []Access is nil the role will remove form Permission.
func (*Permission) Validate ¶ added in v0.1.0
func (p *Permission) Validate(pValidate *PValidate) bool
Validate validates the permission for middleware functions
type Profile ¶
type Profile struct { ID string `bson:"_id" json:"profile_id" validate:"required"` UserID string `bson:"user_id" json:"user_id" validate:"required"` FirstName string `bson:"first_name" json:"first_name" validate:"required"` LastName string `bson:"last_name" json:"last_name" validate:"required"` FullName string `bson:"full_name" json:"full_name"` DisplayName string `bson:"display_name" json:"display_name"` Gender string `bson:"gender" json:"gender"` Country string `bson:"country" json:"country"` Avatar Avatar `bson:"avatar" json:"avatar"` Modified Modified `json:"modified" bson:"modified" validation:"required"` }
Profile represents user Profile
type RefreshToken ¶ added in v0.1.0
type RefreshToken struct { UserID string `json:"user_id"` jwt.StandardClaims }
RefreshToken represents the refresh token contained in JWTToken
type User ¶
type User struct { ID string `json:"user_id" bson:"_id" validation:"required,uuid"` Email string `json:"email" bson:"email" validation:"required,email"` PrivacyPolicy string `json:"policies" bson:"-"` Permission Permission `json:"permission" bson:"permission" validation:"required"` Modified Modified `json:"modified" bson:"modified" validation:"required"` Country string `json:"country" bson:"country" validation:"required"` Profile Profile `json:"profile" bson:"-"` }
User represents the root struct for user handling in viva-con-agua api.
func (*User) CrmDataBody ¶ added in v0.1.4
func (u *User) CrmDataBody(civiID int, activity string) *civi.CrmDataBody
CrmDataBody creates a crm data body from vmod.User