Skip to content

Commit

Permalink
fix: 223 - allow the user to join organization by access code until t…
Browse files Browse the repository at this point in the history
…he end of the end date validity of the access code
  • Loading branch information
Birloi Florian authored and Birloi Florian committed Aug 20, 2024
1 parent b6832c2 commit 4f705aa
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 4f705aa

Please sign in to comment.