Documentation
¶
Index ¶
- type Permission
- type PermissionRepo
- type Role
- type RoleRepo
- type Store
- func (s *Store) GetUser(ctx context.Context, userID int) (User, error)
- func (s *Store) GetUserByEmail(ctx context.Context, email string) (User, error)
- func (s *Store) GetUserByEmailFull(ctx context.Context, email string) (UserFull, error)
- func (s *Store) GetUserFull(ctx context.Context, userID int) (UserFull, error)
- func (s *Store) ListAllPermissions(ctx context.Context) ([]Permission, error)
- func (s *Store) ListAllRoles(ctx context.Context) ([]Role, error)
- func (s *Store) ListAllUsers(ctx context.Context) ([]User, error)
- func (s *Store) ListPermissionMembersByID(ctx context.Context, permissionID int) ([]User, error)
- func (s *Store) ListRoleMembersByID(ctx context.Context, roleID int) ([]User, error)
- func (s *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) GetUserByEmail ¶ added in v0.9.5
GetUserByEmail returns basic user information to be used for other services.
func (*Store) GetUserByEmailFull ¶ added in v0.9.5
GetUserByEmailFull will return all user information to be used for profile and management.
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 (s *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
ListRoleMembersByID 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"` UseGravatar bool `db:"use_gravatar" json:"useGravatar"` 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 null.Time `db:"last_login" json:"lastLogin,omitempty"` CreatedAt null.Time `db:"created_at" json:"createdAt,omitempty"` CreatedBy int `db:"created_by" json:"createdBy,omitempty"` UpdatedAt null.Time `db:"updated_at" json:"updatedAt,omitempty"` UpdatedBy null.Int `db:"updated_by" json:"updatedBy,omitempty"` DeletedAt null.Time `db:"deleted_at" json:"deletedAt,omitempty"` DeletedBy null.Int `db:"deleted_by" json:"deletedBy,omitempty"` Roles []Role `json:"roles,omitempty"` }
UserFull represents a user and all columns
type UserRepo ¶
type UserRepo interface { GetUser(ctx context.Context, userID int) (User, error) GetUserFull(ctx context.Context, userID int) (UserFull, error) GetUserByEmail(ctx context.Context, email string) (User, error) GetUserByEmailFull(ctx context.Context, email string) (UserFull, error) ListAllUsers(ctx context.Context) ([]User, error) }
UserRepo defines all user interactions