Remove backend inactive profile validation
Users are created with state=INACTIVE and only become ACTIVE on first login. The server-side state check incorrectly rejected newly-created users who hadn't yet activated their accounts. The frontend filter (state: ACTIVE) is the correct layer to hide deactivated people from the recipient picker. The existing contract end date validation remains as server-side defense in depth. Co-authored-by: Émile Ré <nemile.re@gmail.com> Signed-off-by: Émile Ré <emile@getprobo.com> Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -97,10 +97,6 @@ type (
|
|||||||
ProfileID gid.GID
|
ProfileID gid.GID
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrProfileInactive struct {
|
|
||||||
ProfileID gid.GID
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateDocumentRequest struct {
|
CreateDocumentRequest struct {
|
||||||
OrganizationID gid.GID
|
OrganizationID gid.GID
|
||||||
Title string
|
Title string
|
||||||
@@ -282,10 +278,6 @@ func (e ErrProfileContractEnded) Error() string {
|
|||||||
return fmt.Sprintf("cannot use profile %q: contract has ended", e.ProfileID)
|
return fmt.Sprintf("cannot use profile %q: contract has ended", e.ProfileID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ErrProfileInactive) Error() string {
|
|
||||||
return fmt.Sprintf("cannot use profile %q: profile is inactive", e.ProfileID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DocumentService) Get(
|
func (s *DocumentService) Get(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
documentID gid.GID,
|
documentID gid.GID,
|
||||||
@@ -979,9 +971,6 @@ func (s *DocumentService) BulkRequestSignatures(
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
for _, p := range *profiles {
|
for _, p := range *profiles {
|
||||||
if p.State == coredata.ProfileStateInactive {
|
|
||||||
return &ErrProfileInactive{ProfileID: p.ID}
|
|
||||||
}
|
|
||||||
if p.ContractEndDate != nil && p.ContractEndDate.Before(now) {
|
if p.ContractEndDate != nil && p.ContractEndDate.Before(now) {
|
||||||
return &ErrProfileContractEnded{ProfileID: p.ID}
|
return &ErrProfileContractEnded{ProfileID: p.ID}
|
||||||
}
|
}
|
||||||
@@ -1093,10 +1082,6 @@ func (s *DocumentService) RequestSignature(
|
|||||||
return fmt.Errorf("cannot load signatory profile: %w", err)
|
return fmt.Errorf("cannot load signatory profile: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if profile.State == coredata.ProfileStateInactive {
|
|
||||||
return &ErrProfileInactive{ProfileID: profile.ID}
|
|
||||||
}
|
|
||||||
|
|
||||||
if profile.ContractEndDate != nil && profile.ContractEndDate.Before(time.Now()) {
|
if profile.ContractEndDate != nil && profile.ContractEndDate.Before(time.Now()) {
|
||||||
return &ErrProfileContractEnded{ProfileID: profile.ID}
|
return &ErrProfileContractEnded{ProfileID: profile.ID}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1296,10 +1296,6 @@ func (r *mutationResolver) RequestSignature(ctx context.Context, input types.Req
|
|||||||
return nil, gqlutils.Conflict(ctx, errContractEnded)
|
return nil, gqlutils.Conflict(ctx, errContractEnded)
|
||||||
}
|
}
|
||||||
|
|
||||||
if errInactive, ok := errors.AsType[*probo.ErrProfileInactive](err); ok {
|
|
||||||
return nil, gqlutils.Conflict(ctx, errInactive)
|
|
||||||
}
|
|
||||||
|
|
||||||
r.logger.ErrorCtx(ctx, "cannot request signature", log.Error(err))
|
r.logger.ErrorCtx(ctx, "cannot request signature", log.Error(err))
|
||||||
return nil, gqlutils.Internal(ctx)
|
return nil, gqlutils.Internal(ctx)
|
||||||
}
|
}
|
||||||
@@ -1345,10 +1341,6 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type
|
|||||||
return nil, gqlutils.Conflict(ctx, errContractEnded)
|
return nil, gqlutils.Conflict(ctx, errContractEnded)
|
||||||
}
|
}
|
||||||
|
|
||||||
if errInactive, ok := errors.AsType[*probo.ErrProfileInactive](err); ok {
|
|
||||||
return nil, gqlutils.Conflict(ctx, errInactive)
|
|
||||||
}
|
|
||||||
|
|
||||||
r.logger.ErrorCtx(ctx, "cannot bulk request signatures", log.Error(err))
|
r.logger.ErrorCtx(ctx, "cannot bulk request signatures", log.Error(err))
|
||||||
return nil, gqlutils.Internal(ctx)
|
return nil, gqlutils.Internal(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user