new features
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func (s *Service) GetAllPermissions(ctx context.Context) ([]models.Permission, error) {
|
||||
return s.positions.GetAllPermissions(ctx)
|
||||
return s.positions.GetAllPermissions(ctx, "en")
|
||||
}
|
||||
|
||||
func (s *Service) AddPermissionToPosition(ctx context.Context, positionCode, permissionCode string) error {
|
||||
@@ -54,6 +54,13 @@ func (s *Service) GetAllPositions(ctx context.Context, locale string) ([]models.
|
||||
return s.positions.GetAllPositions(ctx, locale)
|
||||
}
|
||||
|
||||
func (s *Service) GetUsersWithPositions(ctx context.Context, locale string) ([]models.UserWithPositions, error) {
|
||||
if locale == "" {
|
||||
locale = "en"
|
||||
}
|
||||
return s.positions.GetUsersWithPositions(ctx, locale)
|
||||
}
|
||||
|
||||
func (s *Service) UpsertPositionForLocale(ctx context.Context, code, locale, name string, description *string) error {
|
||||
if locale == "" {
|
||||
locale = "en"
|
||||
@@ -76,7 +83,7 @@ func (s *Service) AssignPosition(ctx context.Context, adminID, targetUserID uuid
|
||||
validFrom = time.Now()
|
||||
}
|
||||
|
||||
return s.positions.AssignPosition(ctx, targetUserID, position.ID, &adminID, validFrom, (*interface{})(nil))
|
||||
return s.positions.AssignPosition(ctx, targetUserID, position.ID, &adminID, validFrom, input.ValidTo)
|
||||
}
|
||||
|
||||
func (s *Service) RevokePosition(ctx context.Context, targetUserID uuid.UUID, positionCode string) error {
|
||||
@@ -85,15 +92,32 @@ func (s *Service) RevokePosition(ctx context.Context, targetUserID uuid.UUID, po
|
||||
return models.ErrNotFound
|
||||
}
|
||||
|
||||
if position.Code == "kotosoft_id_staff" {
|
||||
return models.ErrForbidden
|
||||
}
|
||||
|
||||
return s.positions.RevokePosition(ctx, targetUserID, position.ID)
|
||||
}
|
||||
|
||||
func (s *Service) CreatePermission(ctx context.Context, code string, description *string) error {
|
||||
return s.positions.CreatePermission(ctx, code, description)
|
||||
func (s *Service) GetAllPermissionsForLocale(ctx context.Context, locale string) ([]models.Permission, error) {
|
||||
if locale == "" {
|
||||
locale = "en"
|
||||
}
|
||||
return s.positions.GetAllPermissions(ctx, locale)
|
||||
}
|
||||
|
||||
func (s *Service) UpdatePermission(ctx context.Context, code string, description *string) error {
|
||||
return s.positions.UpdatePermission(ctx, code, description)
|
||||
func (s *Service) CreatePermission(ctx context.Context, code, locale string, description *string) error {
|
||||
if locale == "" {
|
||||
locale = "en"
|
||||
}
|
||||
return s.positions.CreatePermission(ctx, code, locale, description)
|
||||
}
|
||||
|
||||
func (s *Service) UpdatePermission(ctx context.Context, code, locale string, description *string) error {
|
||||
if locale == "" {
|
||||
locale = "en"
|
||||
}
|
||||
return s.positions.UpdatePermission(ctx, code, locale, description)
|
||||
}
|
||||
|
||||
func (s *Service) DeletePermission(ctx context.Context, code string) error {
|
||||
@@ -132,7 +156,7 @@ func (s *Service) IntrospectToken(ctx context.Context, token string) (*Introspec
|
||||
positions = []models.PositionLocalized{}
|
||||
}
|
||||
|
||||
allPerms, err := s.positions.GetUserPermissions(ctx, user.ID)
|
||||
allPerms, err := s.positions.GetUserPermissions(ctx, user.ID, "en")
|
||||
if err != nil {
|
||||
return &IntrospectResponse{Active: false}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user