Commit e47c0a6d authored by i.vasilenko@iq-adv.ru's avatar i.vasilenko@iq-adv.ru
Browse files

Merge branch 'rework' into 'main'

Rework

See merge request !7
parents 240f12f3 fe33ef9b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@

</details>

## Postman

Импортировать в Postman `{URL}/api/doc.json`

## Настройка Xdebug (PHPStorm)
<details>
<summary>Инструкция</summary>
+2 −11
Original line number Diff line number Diff line
@@ -46,22 +46,13 @@ security:
        - { path: ^/api/doc, roles: PUBLIC_ACCESS }

        - { path: ^/api/register, roles: PUBLIC_ACCESS }
        - { path: ^/api/register/send, roles: ROLE_USER }
        - { path: ^/api/register/check, roles: ROLE_USER }

        - { path: ^/api/password/reset/check, roles: PUBLIC_ACCESS }
        - { path: ^/api/password/reset, roles: ROLE_USER }
        - { path: ^/api/password/send, roles: PUBLIC_ACCESS }

        - { path: ^/api/profile/recovery, roles: PUBLIC_ACCESS }
        - { path: ^/api/profile/recovery/check, roles: PUBLIC_ACCESS }
        - { path: ^/api/profile/reset/email, roles: ROLE_USER }
        - { path: ^/api/profile/reset/field, roles: ROLE_USER }
        - { path: ^/api/profile/change, roles: ROLE_USER }
        - { path: ^/api/profile, roles: ROLE_USER }
        - { path: ^/api,       roles: ROLE_CONFIRMED }

        - { path: ^/api,       roles: ROLE_USER }
        # - { path: ^/admin, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }

when@test:
    security:
+67 −9
Original line number Diff line number Diff line
@@ -4,12 +4,15 @@ namespace App\Controller;

use App\Service\Action\ActionServiceInterface;
use App\Service\Dto\Classes\ChangePasswordDto;
use App\Service\Dto\Classes\LoginDto;
use App\Service\Dto\Classes\RecoveryDto;
use App\Service\Dto\Classes\RegisterCodeDto;
use App\Service\Dto\Classes\RegisterDto;
use App\Service\Dto\Classes\ResetPasswordCodeDto;
use App\Service\Response\Classes\Response;
use App\Service\Response\Classes\TokenResponse;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -18,19 +21,37 @@ use OpenApi\Attributes as OA;

#[Route('/api', name: 'api_')]
#[OA\Tag(name: 'Авторизация')]
class AuthController extends AbstractController
{
    #[Route('/login', name: 'get_token', methods: ['POST'])]
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: LoginDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
        ref: new Model(type: Response::class, groups: ["message"])
            ref: new Model(type: TokenResponse::class, groups: ["message", "data"])
        )
    )]
class AuthController extends AbstractController
    #[Security(name: null)]
    public function getToken()
    {
        // Заглушка для Swagger
    }

    #[Route('/register', name: 'register', methods: ['POST'])]
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: RegisterDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    #[Security(name: null)]
    public function register(
        #[Autowire(service: 'action.register')]
        ActionServiceInterface $actionService
@@ -39,7 +60,14 @@ class AuthController extends AbstractController
        return $actionService->getResponse();
    }

    #[Route('/register/send', name: 'register_send', methods: ['GET'])]
    #[Route('/email/send', name: 'email_send', methods: ['GET'])]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    public function sendRegisterCode(
        #[Autowire(service: 'action.register.send')]
        ActionServiceInterface $actionService,
@@ -48,10 +76,17 @@ class AuthController extends AbstractController
        return $actionService->getResponse();
    }

    #[Route('/register/check', name: 'register_check', methods: ['POST'])]
    #[Route('/email/check', name: 'email_check', methods: ['POST'])]
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: RegisterCodeDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    public function checkRegisterCode(
        #[Autowire(service: 'action.register.code')]
        ActionServiceInterface $actionService
@@ -64,6 +99,13 @@ class AuthController extends AbstractController
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: ChangePasswordDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    public function resetPassword(
        #[Autowire(service: 'action.reset.password.change')]
        ActionServiceInterface $actionService
@@ -76,6 +118,14 @@ class AuthController extends AbstractController
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: RecoveryDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    #[Security(name: null)]
    public function sendResetPassword(
        #[Autowire(service: 'action.reset.password.send')]
        ActionServiceInterface $actionService
@@ -88,6 +138,14 @@ class AuthController extends AbstractController
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: ResetPasswordCodeDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    #[Security(name: null)]
    public function resetCheckPassword(
        #[Autowire(service: 'action.reset.password.code')]
        ActionServiceInterface $actionService
+4 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use App\Service\Response\Classes\QuestsResponse;
use App\Service\Response\Classes\Response;
use App\Service\Response\Classes\ReviewsResponse;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -114,6 +115,7 @@ class ProfileController extends AbstractController
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    #[Security(name: null)]
    public function recoveryProfile(
        #[Autowire(service: 'action.recovery.send')]
        ActionServiceInterface $actionService,
@@ -133,6 +135,7 @@ class ProfileController extends AbstractController
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    #[Security(name: null)]
    public function recoveryCodeProfile(
        #[Autowire(service: 'action.recovery.code')]
        ActionServiceInterface $actionService,
@@ -160,7 +163,7 @@ class ProfileController extends AbstractController
        return $actionService->getResponse();
    }

    #[Route('/profile/reset/email', name: 'profile_reset_email', methods: ['GET'])]
    #[Route('/profile/email/reset', name: 'profile_email_reset', methods: ['GET'])]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
+1 −4
Original line number Diff line number Diff line
@@ -149,13 +149,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
    {
        $roles = $this->roles;
        // guarantee every user at least has ROLE_USER
        $roles[] = 'ROLE_USER';
        if ($this->isDeleted()) {
            $roles[] = 'ROLE_DELETED';
        } else if ($this->isConfirm()) {
            $roles[] = 'ROLE_CONFIRMED';
        } else {
            $roles[] = 'ROLE_NOT_CONFIRMED';
            $roles[] = 'ROLE_USER';
        }

        return array_unique($roles);
Loading