user

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountUsers added in v0.7.1

type CountUsers struct {
	TotalUsers             int `db:"total_users" json:"totalUsers"`
	ActiveUsers            int `db:"active_users" json:"activeUsers"`
	ActiveUsersPast24Hours int `db:"active_users_past_24_hours" json:"activeUsersPast24Hours"`
	ActiveUsersPastYear    int `db:"active_users_past_year" json:"activeUsersPastYear"`
}

type DetailedUser added in v0.7.1

type DetailedUser struct {
	UserID             int                     `json:"id"`
	Username           string                  `json:"username"`
	UniversityUsername null.String             `json:"universityUsername"`
	LDAPUsername       null.String             `json:"LDAPUsername"`
	LoginType          string                  `json:"loginType"`
	Nickname           string                  `json:"nickname"`
	Firstname          string                  `json:"firstName"`
	Lastname           string                  `json:"lastName"`
	Avatar             string                  `json:"avatar"`
	UseGravatar        bool                    `json:"useGravatar"`
	Email              string                  `json:"email"`
	LastLogin          null.String             `json:"lastLogin"`
	ResetPw            bool                    `json:"resetPw"`
	Enabled            bool                    `json:"enabled"`
	CreatedAt          null.String             `json:"createdAt"`
	CreatedBy          User                    `json:"createdBy"`
	UpdatedAt          null.String             `json:"updatedAt"`
	UpdatedBy          User                    `json:"updatedBy"`
	DeletedAt          null.String             `json:"deletedAt"`
	DeletedBy          User                    `json:"deletedBy"`
	Gravatar           null.String             `json:"gravatar"`
	Permissions        []permission.Permission `json:"permissions"`
	Roles              []role.Role             `json:"roles"`
}

DetailedUser is the user object in full for the front end

type PermissionTemplate added in v0.7.1

type PermissionTemplate struct {
	PermissionID int
	Name         string
	Description  string
	Roles        []role.Role
}

PermissionTemplate is for the front end of permission

type RolePermission added in v0.7.1

type RolePermission struct {
	RoleID       int `db:"role_id" json:"roleID"`
	PermissionID int `db:"permission_id" json:"permissionID"`
}

RolePermission symbolises a link between a role.Role and permission.Permission

type RoleTemplate added in v0.7.1

type RoleTemplate struct {
	RoleID      int
	Name        string
	Description string
	Permissions []permission.Permission
	Users       []User
}

type RoleUser added in v0.7.1

type RoleUser struct {
	RoleID int `db:"role_id" json:"roleID"`
	UserID int `db:"user_id" json:"userID"`
}

RoleUser symbolises a link between a role.Role and User

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store stores the dependencies

func NewUserRepo

func NewUserRepo(db *sqlx.DB) *Store

NewUserRepo stores our dependency

func (*Store) AddRolePermission added in v0.7.1

func (s *Store) AddRolePermission(ctx context.Context, rp RolePermission) (RolePermission, error)

AddRolePermission creates a link between a role.Role and permission.Permission

func (*Store) AddRoleUser added in v0.7.1

func (s *Store) AddRoleUser(ctx context.Context, ru RoleUser) (RoleUser, error)

AddRoleUser adds a link between a role.Role and User

func (*Store) AddUser added in v0.7.1

func (s *Store) AddUser(ctx context.Context, u User, userID int) (User, error)

AddUser adds a new User

func (*Store) CountUsersAll added in v0.7.1

func (s *Store) CountUsersAll(ctx context.Context) (CountUsers, error)

CountUsersAll returns the number of users, active users, active users in the last 24 hours and past year

func (*Store) DeleteUser added in v0.7.1

func (s *Store) DeleteUser(ctx context.Context, u User, userID int) error

DeleteUser will soft delete a user

func (*Store) EditUser added in v0.7.1

func (s *Store) EditUser(ctx context.Context, u User, userID int) error

EditUser will edit the user

func (*Store) EditUserPassword added in v0.7.1

func (s *Store) EditUserPassword(ctx context.Context, u User) error

EditUserPassword will edit the password and set the reset_pw to false

func (*Store) GetPermissionsForRole added in v0.7.1

func (s *Store) GetPermissionsForRole(ctx context.Context, r role.Role) ([]permission.Permission, error)

GetPermissionsForRole returns all permissions for role

func (*Store) GetPermissionsForUser added in v0.7.1

func (s *Store) GetPermissionsForUser(ctx context.Context, u User) ([]permission.Permission, error)

GetPermissionsForUser returns all permissions of a user

func (*Store) GetPermissionsNotInRole added in v0.7.1

func (s *Store) GetPermissionsNotInRole(ctx context.Context, r role.Role) ([]permission.Permission, error)

GetPermissionsNotInRole returns all the permission.Permission not in a role.Role

func (*Store) GetRolePermission added in v0.7.1

func (s *Store) GetRolePermission(ctx context.Context, rp RolePermission) (RolePermission, error)

GetRolePermission returns the role permission

func (*Store) GetRoleUser added in v0.7.1

func (s *Store) GetRoleUser(ctx context.Context, ru RoleUser) (RoleUser, error)

GetRoleUser returns a single link between a role.Role and User

func (*Store) GetRolesForPermission added in v0.7.1

func (s *Store) GetRolesForPermission(ctx context.Context, p permission.Permission) ([]role.Role, error)

GetRolesForPermission returns all roles where a permission is used

func (*Store) GetRolesForUser added in v0.7.1

func (s *Store) GetRolesForUser(ctx context.Context, u User) ([]role.Role, error)

GetRolesForUser returns all roles of a user

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, u User) (User, error)

GetUser returns a user using any unique identity fields

func (*Store) GetUserValid added in v0.7.1

func (s *Store) GetUserValid(ctx context.Context, u User) (User, error)

GetUserValid returns a user using any unique identity fields which is enabled and not deleted

func (*Store) GetUsers

func (s *Store) GetUsers(ctx context.Context, size, page int, search, sortBy, direction, enabled, deleted string) ([]User, int, error)

func (*Store) GetUsersForRole added in v0.7.1

func (s *Store) GetUsersForRole(ctx context.Context, r role.Role) ([]User, error)

GetUsersForRole returns all the Users that are linked to a role.Role

func (*Store) GetUsersNotInRole added in v0.7.1

func (s *Store) GetUsersNotInRole(ctx context.Context, r role.Role) ([]User, error)

GetUsersNotInRole returns all the users not linked to a role.Role

func (*Store) RemoveRolePermission added in v0.7.1

func (s *Store) RemoveRolePermission(ctx context.Context, rp RolePermission) error

RemoveRolePermission removes a link between a role.Role and permission.Permission

func (*Store) RemoveRoleUser added in v0.7.1

func (s *Store) RemoveRoleUser(ctx context.Context, ru RoleUser) error

RemoveRoleUser removes a link between a role.Role and User

func (*Store) RemoveRoleUsers added in v0.7.1

func (s *Store) RemoveRoleUsers(ctx context.Context, u User) error

func (*Store) SetUserLoggedIn

func (s *Store) SetUserLoggedIn(ctx context.Context, u User) error

SetUserLoggedIn will set the last login date to now

func (*Store) VerifyUser

func (s *Store) VerifyUser(ctx context.Context, u User) (User, bool, error)

VerifyUser will check that the password is correct with provided credentials and if verified will return the User object returned is the user object, bool of if the password is forced to be changed and any errors encountered

type StrippedUser added in v0.7.1

type StrippedUser struct {
	UserID    int
	Username  string
	Name      string
	Email     string
	LastLogin string
	Enabled   bool
	Deleted   bool
}

StrippedUser represents user information, an administrator can view

type User added in v0.6.0

type User struct {
	UserID             int                     `db:"user_id" json:"userID"`
	Username           string                  `db:"username" json:"username" schema:"username"`
	UniversityUsername null.String             `db:"university_username" json:"universityUsername"`
	LDAPUsername       null.String             `db:"ldap_username" json:"LDAPUsername"`
	LoginType          string                  `db:"login_type" json:"loginType"`
	Nickname           string                  `db:"nickname" json:"nickname" schema:"nickname"`
	Firstname          string                  `db:"first_name" json:"firstName" schema:"firstname"`
	Lastname           string                  `db:"last_name" json:"lastName" schema:"lastname"`
	Password           null.String             `db:"password" json:"-" schema:"password"`
	Salt               null.String             `db:"salt" json:"-"`
	Avatar             string                  `db:"avatar" json:"avatar" schema:"avatar"`
	Email              string                  `db:"email" json:"email" schema:"email"`
	LastLogin          null.Time               `db:"last_login" json:"lastLogin"`
	ResetPw            bool                    `db:"reset_pw" json:"resetPw"`
	Enabled            bool                    `db:"enabled" json:"enabled"`
	CreatedAt          null.Time               `db:"created_at" json:"createdAt"`
	CreatedBy          null.Int                `db:"created_by" json:"createdBy"`
	UpdatedAt          null.Time               `db:"updated_at" json:"updatedAt"`
	UpdatedBy          null.Int                `db:"updated_by" json:"updatedBy"`
	DeletedAt          null.Time               `db:"deleted_at" json:"deletedAt"`
	DeletedBy          null.Int                `db:"deleted_by" json:"deletedBy"`
	UseGravatar        bool                    `db:"use_gravatar" json:"useGravatar" schema:"useGravatar"`
	Permissions        []permission.Permission `json:"permissions"`
	Roles              []role.Role             `json:"roles"`
	Authenticated      bool                    `json:"authenticated"`
	AssumedUser        *User                   `json:"assumedUser"`
}

User represents relevant user fields

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL