diff --git a/backend/openapi/components/responses/internal/error-participant-token-still-valid.yaml b/backend/openapi/components/responses/internal/error-participant-token-still-valid.yaml deleted file mode 100644 index 20f17dc..0000000 --- a/backend/openapi/components/responses/internal/error-participant-token-still-valid.yaml +++ /dev/null @@ -1,8 +0,0 @@ -description: Conflict — Current token is still valid -content: - application/json: - schema: - $ref: '../../schemas/error.yaml' - example: - error: Participant Error - message: 'Participant token is still valid' diff --git a/backend/openapi/paths/internal/participants.yaml b/backend/openapi/paths/internal/participants.yaml index a1c42b4..8932a45 100644 --- a/backend/openapi/paths/internal/participants.yaml +++ b/backend/openapi/paths/internal/participants.yaml @@ -50,8 +50,6 @@ $ref: '../../components/responses/forbidden-error.yaml' '404': $ref: '../../components/responses/internal/error-room-participant-not-found.yaml' - '409': - $ref: '../../components/responses/internal/error-participant-token-still-valid.yaml' '422': $ref: '../../components/responses/validation-error.yaml' '500': diff --git a/backend/src/controllers/participant.controller.ts b/backend/src/controllers/participant.controller.ts index 2daa2cc..f0b01a3 100644 --- a/backend/src/controllers/participant.controller.ts +++ b/backend/src/controllers/participant.controller.ts @@ -5,7 +5,6 @@ import INTERNAL_CONFIG from '../config/internal-config.js'; import { errorInvalidParticipantToken, errorParticipantTokenNotPresent, - errorParticipantTokenStillValid, handleError, rejectRequestFromMeetError } from '../models/error.model.js'; @@ -57,29 +56,17 @@ export const generateParticipantToken = async (req: Request, res: Response) => { export const refreshParticipantToken = async (req: Request, res: Response) => { const logger = container.get(LoggerService); - // Check if there is a previous token and if it is expired + // Check if there is a previous token const previousToken = req.cookies[INTERNAL_CONFIG.PARTICIPANT_TOKEN_COOKIE_NAME]; - // If there is no previous token, we cannot refresh it if (!previousToken) { logger.verbose('No previous participant token found. Cannot refresh.'); const error = errorParticipantTokenNotPresent(); return rejectRequestFromMeetError(res, error); } - const tokenService = container.get(TokenService); - - // If the previous token is still valid, we do not need to refresh it - try { - await tokenService.verifyToken(previousToken); - logger.verbose('Previous participant token is valid. No need to refresh'); - const error = errorParticipantTokenStillValid(); - return rejectRequestFromMeetError(res, error); - } catch (error) { - // Previous token is expired, we can proceed to refresh it - } - // Extract roles from the previous token + const tokenService = container.get(TokenService); const participantService = container.get(ParticipantService); let currentRoles: { role: ParticipantRole; permissions: OpenViduMeetPermissions }[] = []; diff --git a/backend/src/models/error.model.ts b/backend/src/models/error.model.ts index f740192..d1f3fe4 100644 --- a/backend/src/models/error.model.ts +++ b/backend/src/models/error.model.ts @@ -230,10 +230,6 @@ export const errorParticipantAlreadyExists = (participantIdentity: string, roomI ); }; -export const errorParticipantTokenStillValid = (): OpenViduMeetError => { - return new OpenViduMeetError('Participant Error', 'Participant token is still valid', 409); -}; - export const errorParticipantTokenNotPresent = (): OpenViduMeetError => { return new OpenViduMeetError('Participant', 'No participant token provided', 400); }; diff --git a/backend/tests/integration/api/participants/refresh-token.test.ts b/backend/tests/integration/api/participants/refresh-token.test.ts index 160826c..d5f54d4 100644 --- a/backend/tests/integration/api/participants/refresh-token.test.ts +++ b/backend/tests/integration/api/participants/refresh-token.test.ts @@ -119,20 +119,6 @@ describe('Participant API Tests', () => { ); expect(response.status).toBe(404); }); - - it('should fail with 409 when participant token is still valid', async () => { - const newRoomData = await setupSingleRoom(true); - const response = await refreshParticipantToken( - { - roomId: newRoomData.room.roomId, - secret: newRoomData.moderatorSecret, - participantName - }, - newRoomData.moderatorCookie - ); - expect(response.status).toBe(409); - expect(response.body.message).toBe('Participant token is still valid'); - }); }); describe('Refresh Participant Token Validation Tests', () => { diff --git a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts index f26bc68..fc56acd 100644 --- a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts +++ b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts @@ -56,13 +56,6 @@ export const httpInterceptor: HttpInterceptorFn = (req: HttpRequest, ne }), catchError((error: HttpErrorResponse) => { if (error.url?.includes('/token/refresh')) { - if (error.status === 409) { - console.log('Participant token is still valid'); - // This means that the unauthorized error was due to an expired access token - // Refresh the access token and try again - return refreshAccessToken(firstError); - } - console.error('Error refreshing participant token'); throw firstError; } diff --git a/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts b/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts index c68f8cb..e541888 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/participant.service.ts @@ -77,7 +77,6 @@ export class ParticipantService { livekit: decodedToken.video, openvidu: openviduPermissions }; - console.warn('PARTICIPANT PERMISSIONS', this.permissions); // Update feature configuration this.featureConfService.setParticipantRole(this.role);