Documentation
¶
Index ¶
- type AccountRepo
- func (a *AccountRepo) ChangePassword(u *model.User) error
- func (a *AccountRepo) Create(u *model.User) (*model.User, error)
- func (a *AccountRepo) CreateAndVerify(u *model.User) (*model.Verification, error)
- func (a *AccountRepo) CreateWithMobile(u *model.User) error
- func (a *AccountRepo) DeleteVerificationToken(v *model.Verification) error
- func (a *AccountRepo) FindVerificationToken(token string) (*model.Verification, error)
- type RBACService
- func (s *RBACService) AccountCreate(c *gin.Context, roleID, companyID, locationID int) bool
- func (s *RBACService) EnforceCompany(c *gin.Context, ID int) bool
- func (s *RBACService) EnforceLocation(c *gin.Context, ID int) bool
- func (s *RBACService) EnforceRole(c *gin.Context, r model.AccessRole) bool
- func (s *RBACService) EnforceUser(c *gin.Context, ID int) bool
- func (s *RBACService) IsLowerRole(c *gin.Context, r model.AccessRole) bool
- type RoleRepo
- type UserRepo
- func (u *UserRepo) Delete(user *model.User) error
- func (u *UserRepo) FindByEmail(email string) (*model.User, error)
- func (u *UserRepo) FindByMobile(countryCode, mobile string) (*model.User, error)
- func (u *UserRepo) FindByToken(token string) (*model.User, error)
- func (u *UserRepo) FindByUsername(username string) (*model.User, error)
- func (u *UserRepo) List(qp *model.ListQuery, p *model.Pagination) ([]model.User, error)
- func (u *UserRepo) Update(user *model.User) (*model.User, error)
- func (u *UserRepo) UpdateLogin(user *model.User) error
- func (u *UserRepo) View(id int) (*model.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountRepo ¶
AccountRepo represents the client for the user table
func NewAccountRepo ¶
NewAccountRepo returns an AccountRepo instance
func (*AccountRepo) ChangePassword ¶
func (a *AccountRepo) ChangePassword(u *model.User) error
ChangePassword changes user's password
func (*AccountRepo) CreateAndVerify ¶
func (a *AccountRepo) CreateAndVerify(u *model.User) (*model.Verification, error)
CreateAndVerify creates a new user in our database, and generates a verification token. User active being false until after verification.
func (*AccountRepo) CreateWithMobile ¶
func (a *AccountRepo) CreateWithMobile(u *model.User) error
CreateWithMobile creates a new user in our database with country code and mobile number
func (*AccountRepo) DeleteVerificationToken ¶
func (a *AccountRepo) DeleteVerificationToken(v *model.Verification) error
DeleteVerificationToken sets deleted_at for an existing verification token
func (*AccountRepo) FindVerificationToken ¶
func (a *AccountRepo) FindVerificationToken(token string) (*model.Verification, error)
FindVerificationToken retrieves an existing verification token
type RBACService ¶
type RBACService struct {
// contains filtered or unexported fields
}
RBACService is RBAC application service
func NewRBACService ¶
func NewRBACService(userRepo model.UserRepo) *RBACService
NewRBACService creates new RBAC service
func (*RBACService) AccountCreate ¶
func (s *RBACService) AccountCreate(c *gin.Context, roleID, companyID, locationID int) bool
AccountCreate performs auth check when creating a new account Location admin cannot create accounts, needs to be fixed on EnforceLocation function
func (*RBACService) EnforceCompany ¶
func (s *RBACService) EnforceCompany(c *gin.Context, ID int) bool
EnforceCompany checks whether the request to apply change to company data is done by the user belonging to the that company and that the user has role CompanyAdmin. If user has admin role, the check for company doesnt need to pass.
func (*RBACService) EnforceLocation ¶
func (s *RBACService) EnforceLocation(c *gin.Context, ID int) bool
EnforceLocation checks whether the request to change location data is done by the user belonging to the requested location
func (*RBACService) EnforceRole ¶
func (s *RBACService) EnforceRole(c *gin.Context, r model.AccessRole) bool
EnforceRole authorizes request by AccessRole
func (*RBACService) EnforceUser ¶
func (s *RBACService) EnforceUser(c *gin.Context, ID int) bool
EnforceUser checks whether the request to change user data is done by the same user
func (*RBACService) IsLowerRole ¶
func (s *RBACService) IsLowerRole(c *gin.Context, r model.AccessRole) bool
IsLowerRole checks whether the requesting user has higher role than the user it wants to change Used for account creation/deletion
type RoleRepo ¶
type RoleRepo struct {
// contains filtered or unexported fields
}
RoleRepo represents the client for the role table
func NewRoleRepo ¶
NewRoleRepo returns a Role Repo instance
func (*RoleRepo) CreateRoles ¶
CreateRoles creates role objects in our database
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
UserRepo is the client for our user model
func NewUserRepo ¶
NewUserRepo returns a new UserRepo instance
func (*UserRepo) FindByEmail ¶
FindByEmail queries for a single user by email
func (*UserRepo) FindByMobile ¶
FindByMobile queries for a single user by mobile (and country code)
func (*UserRepo) FindByToken ¶
FindByToken queries for single user by token
func (*UserRepo) FindByUsername ¶
FindByUsername queries for a single user by username
func (*UserRepo) List ¶
List returns list of all users retreivable for the current user, depending on role
func (*UserRepo) UpdateLogin ¶
UpdateLogin updates last login and refresh token for user