Documentation
¶
Index ¶
- type Permission
- type PermissionRepo
- type Role
- type RoleRepo
- type Store
- func (m *Store) GetUser(ctx context.Context, userID int) (User, error)
- func (m *Store) GetUserFull(ctx context.Context, userID int) (UserFull, error)
- func (m *Store) ListAllPermissions(ctx context.Context) ([]Permission, error)
- func (s *Store) ListAllRoles(ctx context.Context) ([]Role, error)
- func (m *Store) ListAllUsers(ctx context.Context) ([]User, error)
- func (m *Store) ListPermissionMembersByID(ctx context.Context, permissionID int) ([]User, error)
- func (m *Store) ListRoleMembersByID(ctx context.Context, roleID int) ([]User, error)
- func (m *Store) ListRolePermissionsByID(ctx context.Context, roleID int) ([]Permission, error)
- type User
- type UserFull
- type UserRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Permission ¶
type Permission struct {
PermissionID int `db:"permission_id" json:"id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description,omitempty"`
}
Permission represents an individual permission. Attempting to implement some RBAC here.
type PermissionRepo ¶
type PermissionRepo interface {
ListAllPermissions(ctx context.Context) ([]Permission, error)
ListPermissionMembersByID(ctx context.Context, permissionID int) ([]User, error)
}
PermissionRepo defines all permission interactions
type Role ¶
type Role struct {
RoleID int `db:"role_id" json:"id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
Permissions []Permission `json:"permissions"`
}
Role represents a "group" of permissions where multiple users can have this role and they will inherit these permissions.
type RoleRepo ¶ added in v0.8.0
type RoleRepo interface {
ListAllRoles(ctx context.Context) ([]Role, error)
ListRoleMembersByID(ctx context.Context, roleID int) ([]User, error)
ListRolePermissionsByID(ctx context.Context, roleID int) ([]Permission, error)
}
RoleRepo defines all role interaction
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store contains our dependency
func (*Store) GetUser ¶ added in v0.8.0
GetUser returns basic user information to be used for other services.
func (*Store) GetUserFull ¶ added in v0.8.0
GetUserFull will return all user information to be used for profile and management.
func (*Store) ListAllPermissions ¶ added in v0.8.0
func (m *Store) ListAllPermissions(ctx context.Context) ([]Permission, error)
func (*Store) ListAllRoles ¶ added in v0.8.0
func (*Store) ListAllUsers ¶ added in v0.8.0
ListAllUsers returns all users It doesn't return the full User object Returns user_id, avatar, nickname, first_name, last_name
There will likely be modifications to include the other fields but will need to add a filter at the web handler first or offer a different function.
func (*Store) ListPermissionMembersByID ¶ added in v0.8.0
func (*Store) ListRoleMembersByID ¶ added in v0.8.0
ListRole returns all users who have a certain role It doesn't return the full User object Returns user_id, avatar, nickname, first_name, last_name
There will likely be modifications to include the other fields but will need to add a filter at the web handler first or offer a different function.
func (*Store) ListRolePermissionsByID ¶ added in v0.8.0
type User ¶
type User struct {
UserID int `db:"user_id" json:"id"`
Username string `db:"username" json:"username,omitempty"`
Email string `db:"email" json:"email,omitempty"`
Nickname string `db:"nickname" json:"nickname"`
Avatar string `db:"avatar" json:"avatar"`
FirstName string `db:"first_name" json:"firstName"`
LastName string `db:"last_name" json:"lastName"`
Permissions []Permission `json:"permissions,omitempty"`
}
User represents a user object to be used when not all data is required
type UserFull ¶
type UserFull struct {
User
LastLogin *time.Time `db:"last_login" json:"lastLogin,omitempty"`
CreatedAt *time.Time `db:"created_at" json:"createdAt,omitempty"`
CreatedBy int `db:"created_by" json:"createdBy,omitempty"`
UpdatedAt *time.Time `db:"updated_at" json:"updatedAt,omitempty"`
UpdatedBy *int `db:"updated_by" json:"updatedBy,omitempty"`
DeletedAt *time.Time `db:"deleted_at" json:"deletedAt,omitempty"`
DeletedBy *int `db:"deleted_by" json:"deletedBy,omitempty"`
Roles []Role `json:"roles,omitempty"`
}
UserFull represents a user and all columns