Skip to content

Commit

Permalink
Merge pull request #365 from code4romania/fix/223-access-code-validity
Browse files Browse the repository at this point in the history
fix: 223 - join organization by access code endDate interval issue
  • Loading branch information
birloiflorian authored Aug 20, 2024
2 parents b6832c2 + 4f705aa commit 319b2c3
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'src/modules/volunteer/model/volunteer.model';
import { CreateVolunteerUseCase } from './create-volunteer.usecase';
import { AccessCodeFacade } from 'src/modules/organization/services/access-code.facade';
import { compareAsc } from 'date-fns';
import { compareAsc, endOfDay, startOfDay } from 'date-fns';
import { AccessCodeExceptionMessages } from 'src/modules/organization/exceptions/access-codes.exceptions';

@Injectable()
Expand Down Expand Up @@ -52,8 +52,9 @@ export class JoinOrganizationByAccessCodeUsecase

// check fi the access code is valid
if (
compareAsc(accessCode.startDate, new Date()) > 0 ||
(accessCode.endDate && compareAsc(accessCode.endDate, new Date()) < 0)
compareAsc(startOfDay(accessCode.startDate), new Date()) > 0 ||
(accessCode.endDate &&
compareAsc(endOfDay(accessCode.endDate), new Date()) < 0)
) {
this.exceptionService.badRequestException(
AccessCodeExceptionMessages.ACCESS_CODE_001,
Expand Down

0 comments on commit 319b2c3

Please sign in to comment.