Documentation ¶
Index ¶
- type Handler
- type PermissionTable
- type PermissionTableJson
- type Permissions
- type Repo
- type RepoSql
- func (repo *RepoSql) CleanUp()
- func (repo *RepoSql) GetPermissions(user users.User) (*Permissions, error)
- func (repo *RepoSql) GetRoleIds(user users.User) ([]int, error)
- func (repo *RepoSql) SetRolesByName(user users.User, roles []string) error
- func (repo *RepoSql) SetRolesByRoleId(user users.User, roles []int) error
- type Role
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
*
- This struct is used
type PermissionTable ¶
type PermissionTable interface { /** Get the user with the email. An error is thrown is not found */ GetPermissions(roleId int) []string //Look up the role id based upon the name LookUpRoleId(name string) (int, error) }
* Define an interface for roles
type PermissionTableJson ¶
* Define a struct for Repo for use with users
func NewPermissionTableJson ¶
func NewPermissionTableJson(fileName string) *PermissionTableJson
Provide a method to make a new UserRepoSql
func (*PermissionTableJson) GetPermissions ¶
func (repo *PermissionTableJson) GetPermissions(roleId int) []string
* Get the user with the email. An error is thrown is not found
func (*PermissionTableJson) LookUpRoleId ¶
func (repo *PermissionTableJson) LookUpRoleId(roleLookUp string) (int, error)
* Get the role id for this name
type Permissions ¶
type Permissions struct { //Store a list of Permissions []string `json:"permissions"` }
* * This package is used to check for roles
func (*Permissions) AllowedTo ¶
func (perm *Permissions) AllowedTo(tasks ...string) bool
* Check to see if the user has permission to do something
type Repo ¶
type Repo interface { /** Get the user with the email. An error is thrown is not found */ GetPermissions(user users.User) (*Permissions, error) /** Set the user's roles. Note this wipes out all current roles */ SetRolesByRoleId(user users.User, roles []int) error /** Set the user's roles. Note this wipes out all current roles */ SetRolesByName(user users.User, roles []string) error }
* Define an interface for roles
type RepoSql ¶
type RepoSql struct {
// contains filtered or unexported fields
}
* Define a struct for Repo for use with users
func NewRepoMySql ¶
func NewRepoMySql(db *sql.DB, tableName string, roleRepo PermissionTable) *RepoSql
Provide a method to make a new UserRepoSql
func NewRepoPostgresSql ¶
func NewRepoPostgresSql(db *sql.DB, tableName string, roleRepo PermissionTable) *RepoSql
Provide a method to make a new UserRepoSql
func (*RepoSql) CleanUp ¶
func (repo *RepoSql) CleanUp()
* Clean up the database, nothing much to do
func (*RepoSql) GetPermissions ¶
func (repo *RepoSql) GetPermissions(user users.User) (*Permissions, error)
* Get the user with the email. An error is thrown is not found
func (*RepoSql) GetRoleIds ¶
* Get all of the roles
func (*RepoSql) SetRolesByName ¶
* Set the user's roles. Note this wipes out all current roles