Skip to content

Commit c54da10

Browse files
authored
th-263: Update logout (#359)
* th-263: + adds a redirect for an unauthorized user * th-263: + adds a swagger for the logout route
1 parent 08327f3 commit c54da10

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

backend/src/packages/auth/auth.controller.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,26 @@ export { AuthController };
390390
* type: string
391391
* example: This email is not registered
392392
*/
393+
394+
/**
395+
* @swagger
396+
* /auth/logout:
397+
* get:
398+
* tags:
399+
* - auth
400+
* description: Log out of the system
401+
* security:
402+
* - {}
403+
* - bearerAuth: []
404+
* responses:
405+
* 204:
406+
* description: Successful operation
407+
* 401:
408+
* UnauthorizedError:
409+
* description:
410+
* You are not authorized
411+
* content:
412+
* plain/text:
413+
* schema:
414+
* $ref: '#/components/schemas/UnauthorizedError'
415+
*/

frontend/src/libs/components/protected-route/protected-route.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { DataStatus } from '~/libs/enums/enums.js';
1+
import { Navigate } from 'react-router-dom';
2+
3+
import { AppRoute, DataStatus } from '~/libs/enums/enums.js';
24
import { useAppSelector } from '~/libs/hooks/hooks.js';
35
import { type ValueOf } from '~/libs/types/types.js';
46
import { type UserGroupKey } from '~/packages/users/libs/enums/enums.js';
5-
import { NotFound } from '~/pages/not-found/not-found.js';
67
import { useAuthUser } from '~/slices/auth/auth.js';
78
import { selectIsLoading } from '~/slices/auth/selectors.js';
89

@@ -26,7 +27,7 @@ const ProtectedRoute = ({
2627
return user && allowedUserGroup === user.group.key ? (
2728
<RouterOutlet />
2829
) : (
29-
<NotFound />
30+
<Navigate to={AppRoute.SIGN_IN} />
3031
);
3132
};
3233

0 commit comments

Comments
 (0)