Documentation
¶
Index ¶
- Constants
- func GetAuthorizationBearerToken(r *http.Request) string
- func GetPermissionFlagsMultipleBitChoice() map[int]string
- func GetPermissionForTypeSingleChoice() map[int]string
- func GetPermissionOpsMultipleBitChoice() map[int]string
- func GetSessionFlagsSingleChoice() map[int]string
- func GetUserIDFromRequest(r *http.Request) int64
- type DefaultUser
- func (g *DefaultUser) CreateDBTable() error
- func (g *DefaultUser) GetByEmail(email string) (bool, error)
- func (g *DefaultUser) GetByEmailActivationKey(key string) (bool, error)
- func (g *DefaultUser) GetByID(id int64) (bool, error)
- func (g *DefaultUser) GetEmail() string
- func (g *DefaultUser) GetEmailActivationKey() string
- func (g *DefaultUser) GetExtraField(n string) string
- func (g *DefaultUser) GetFlags() int64
- func (g *DefaultUser) GetID() int64
- func (g *DefaultUser) GetPassword() string
- func (g *DefaultUser) GetUser() interface{}
- func (g *DefaultUser) Save() error
- func (g *DefaultUser) SetEmail(e string)
- func (g *DefaultUser) SetEmailActivationKey(k string)
- func (g *DefaultUser) SetExtraField(n string, v string)
- func (g *DefaultUser) SetFlags(flags int64)
- func (g *DefaultUser) SetPassword(p string)
- type ErrUmbrella
- type HTTPResponse
- type HandlerConfig
- type Hooks
- type Interfaces
- type JWTConfig
- type ORM
- type ORMError
- type Permission
- type Session
- type Umbrella
- func (u Umbrella) ConfirmEmail(key string) error
- func (u Umbrella) CreateDBTables() error
- func (u Umbrella) CreateUser(email string, pass string, extraFields map[string]string) (string, error)
- func (u Umbrella) GeneratePassword(pass string) (string, error)
- func (u Umbrella) GetHTTPHandler(uri string) http.Handler
- func (u Umbrella) GetHTTPHandlerWrapper(next http.Handler, config HandlerConfig) http.Handler
- func (u Umbrella) GetLoginHTTPHandler(config HandlerConfig) http.Handler
- func (u Umbrella) GetLogoutHTTPHandler(config HandlerConfig) http.Handler
- func (u Umbrella) GetUserOperationAllowedTypes(i int64, o int) (map[string]bool, error)
- type UmbrellaConfig
- type UmbrellaContextValue
- type User
- type UserExtraField
- type UserInterface
Constants ¶
View Source
const DisableCheck = 8
View Source
const DisableConfirm = 2
View Source
const DisableLogin = 4
View Source
const DisableRegister = 1
View Source
const FlagSessionActive = 1
View Source
const FlagSessionLoggedOut = 2
View Source
const FlagTypeAllow = 4
View Source
const FlagUserActive = 1
View Source
const FlagUserAllowLogin = 4
View Source
const FlagUserEmailConfirmed = 2
View Source
const ForTypeEveryone = 1
View Source
const ForTypeUser = 4
View Source
const OpsCreate = 8
View Source
const OpsDelete = 64
View Source
const OpsList = 128
View Source
const OpsRead = 16
View Source
const OpsUpdate = 32
View Source
const RegisterAllowedToLogin = 32
View Source
const RegisterConfirmed = 16
View Source
const VERSION = "0.8.1"
Variables ¶
This section is empty.
Functions ¶
func GetUserIDFromRequest ¶
Types ¶
type DefaultUser ¶
type DefaultUser struct {
// contains filtered or unexported fields
}
DefaultUserModel is default implementation of UserInterface using struct-db-postgres package
func (*DefaultUser) CreateDBTable ¶
func (g *DefaultUser) CreateDBTable() error
func (*DefaultUser) GetByEmail ¶
func (g *DefaultUser) GetByEmail(email string) (bool, error)
func (*DefaultUser) GetByEmailActivationKey ¶
func (g *DefaultUser) GetByEmailActivationKey(key string) (bool, error)
func (*DefaultUser) GetEmail ¶
func (g *DefaultUser) GetEmail() string
func (*DefaultUser) GetEmailActivationKey ¶
func (g *DefaultUser) GetEmailActivationKey() string
func (*DefaultUser) GetExtraField ¶
func (g *DefaultUser) GetExtraField(n string) string
func (*DefaultUser) GetFlags ¶
func (g *DefaultUser) GetFlags() int64
func (*DefaultUser) GetID ¶
func (g *DefaultUser) GetID() int64
func (*DefaultUser) GetPassword ¶
func (g *DefaultUser) GetPassword() string
func (*DefaultUser) GetUser ¶
func (g *DefaultUser) GetUser() interface{}
func (*DefaultUser) Save ¶
func (g *DefaultUser) Save() error
func (*DefaultUser) SetEmail ¶
func (g *DefaultUser) SetEmail(e string)
func (*DefaultUser) SetEmailActivationKey ¶
func (g *DefaultUser) SetEmailActivationKey(k string)
func (*DefaultUser) SetExtraField ¶
func (g *DefaultUser) SetExtraField(n string, v string)
func (*DefaultUser) SetFlags ¶
func (g *DefaultUser) SetFlags(flags int64)
func (*DefaultUser) SetPassword ¶
func (g *DefaultUser) SetPassword(p string)
type ErrUmbrella ¶
ErrUmbrella wraps original error that occurred in Err with name of the operation/step that failed, which is in Op field
func (ErrUmbrella) Error ¶
func (e ErrUmbrella) Error() string
func (ErrUmbrella) Unwrap ¶
func (e ErrUmbrella) Unwrap() error
type HTTPResponse ¶
type HTTPResponse struct { OK int8 `json:"ok"` ErrText string `json:"err_text"` Data map[string]interface{} `json:"data"` }
HTTPResponse is a base structure for all the HTTP responses from HTTP endpoints
func NewHTTPResponse ¶
func NewHTTPResponse(ok int8, errText string) HTTPResponse
NewHTTPResponse returns new HTTPResponse object
type HandlerConfig ¶
type Hooks ¶
type Hooks struct { PostRegisterSuccess func(http.ResponseWriter, string) bool PostConfirmSuccess func(http.ResponseWriter) bool PostLoginSuccess func(http.ResponseWriter, string, string, int64) bool PostCheckSuccess func(http.ResponseWriter, string, int64, bool) bool PostLogoutSuccess func(http.ResponseWriter, string) bool }
type Interfaces ¶
type Interfaces struct {
User func() UserInterface
}
type ORM ¶
type ORM interface { // RegisterStruct initializes a specific object. ORMs often need to reflect the object to get the fields, build SQL queries etc. // When doing that, certain things such as tags can be inherited from another object. This is in the scenario where there is a root object (eg. Product) that contains all the validation tags and // another struct with less fields should be used as an input for API (eg. Product_WithoutCertainFields). In such case, there is no need to re-define tags such as validation. // Parameter `forceNameForDB` allows forcing another struct name (which later is used for generating table name). // This interface is based on the struct2db module and that module allows some cascade operations (such as delete or update). For this to work, and when certain fields are other structs, ORM must go // deeper and initializes that guys as well. When setting useOnlyRootFromInheritedObj to true, it's being avoided. RegisterStruct(obj interface{}, inheritFromObj interface{}, overwriteExisting bool, forceNameForDB string, useOnlyRootFromInheritedObj bool) error // CreateTables create database tables for struct instances CreateTables(objs ...interface{}) error // DeleteMultiple removes struct items by their ids DeleteMultiple(obj interface{}, filters map[string]interface{}) error // Get fetches data from the database and returns struct instances. Hence, it requires a constructor for the returned objects. Apart from the self-explanatory fields, filters in a format of (field name, any value) // can be added, and each returned object (based on a database row) can be transformed into anything else. Get(newObjFunc func() interface{}, order []string, limit int, offset int, filters map[string]interface{}, rowObjTransformFunc func(interface{}) interface{}) ([]interface{}, error) // GetCount returns number of struct items found in the database GetCount(newObjFunc func() interface{}, filters map[string]interface{}) (int64, error) // Load populates struct instance's field values with database values Load(obj interface{}, id string) error // Save stores (creates or updates) struct instance in the appropriate database table Save(obj interface{}) error // Delete removes struct instance from the database table Delete(obj interface{}) error }
type Permission ¶
type Permission struct { ID int64 `json:"id"` Flags int64 `json:"flags"` ForType int8 `json:"for_type"` ForItem int64 `json:"for_item"` Ops int64 `json:"ops"` ToType string `json:"to_type"` ToItem int64 `json:"to_item"` CreatedAt int64 `json:"created_at"` CreatedBy int64 `json:"created_by"` LastModifiedAt int64 `json:"last_modified_at"` LastModifiedBy int64 `json:"last_modified_by"` }
type Umbrella ¶
type Umbrella struct { Hooks *Hooks Interfaces *Interfaces Flags int UserExtraFields []UserExtraField // contains filtered or unexported fields }
func NewUmbrella ¶
func (Umbrella) ConfirmEmail ¶
func (Umbrella) CreateDBTables ¶
func (Umbrella) CreateUser ¶
func (Umbrella) GetHTTPHandlerWrapper ¶
func (Umbrella) GetLoginHTTPHandler ¶
func (u Umbrella) GetLoginHTTPHandler(config HandlerConfig) http.Handler
func (Umbrella) GetLogoutHTTPHandler ¶
func (u Umbrella) GetLogoutHTTPHandler(config HandlerConfig) http.Handler
type UmbrellaConfig ¶
type UmbrellaContextValue ¶
type UmbrellaContextValue string
type User ¶
type User struct { ID int64 `json:"user_id"` Flags int64 `json:"flags"` Name string `json:"name" 2db:"lenmin:0 lenmax:50"` Email string `json:"email" 2db:"req"` Password string `json:"password"` EmailActivationKey string `json:"email_activation_key"` CreatedAt int64 `json:"created_at"` CreatedBy int64 `json:"created_by"` LastModifiedAt int64 `json:"last_modified_at"` LastModifiedBy int64 `json:"last_modified_by"` }
type UserExtraField ¶
type UserInterface ¶
type UserInterface interface { CreateDBTable() error GetID() int64 GetEmail() string SetEmail(string) GetPassword() string SetPassword(string) GetEmailActivationKey() string SetEmailActivationKey(string) GetFlags() int64 SetFlags(int64) GetExtraField(n string) string SetExtraField(n string, v string) Save() error GetByID(int64) (bool, error) GetByEmail(string) (bool, error) GetByEmailActivationKey(string) (bool, error) GetUser() interface{} }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.