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

password reset

user history
profile change
parent 92fe172c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@ security:

        - { 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: ^/admin, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }
+6 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ services:

    App\Service\Action\ActionServiceInterface $resetPasswordService: '@App\Service\Action\Classes\ResetPassword'

    App\Service\Action\ActionServiceInterface $profileChangeService: '@App\Service\Action\Classes\ChangeProfile'

    App\Service\Action\ActionServiceInterface $resetEmailService: '@App\Service\Action\Classes\ResetEmail'

    App\Service\Action\ActionServiceInterface: '@App\Service\Action\Classes\None'


@@ -58,6 +62,8 @@ services:

    App\Service\Dto\DtoServiceInterface $passwordDto: '@App\Service\Dto\Classes\ChangePasswordDto'

    App\Service\Dto\DtoServiceInterface $profileDto: '@App\Service\Dto\Classes\ChangeProfileDto'

    App\Service\Dto\DtoServiceInterface $recoveryDto: '@App\Service\Dto\Classes\RecoveryDto'

    App\Service\Dto\DtoServiceInterface: '@App\Service\Dto\Classes\NoneDto'
+37 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20240620091453 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SEQUENCE user_history_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE user_history (id INT NOT NULL, related_user_id INT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, field VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, old_value VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_7FB76E4198771930 ON user_history (related_user_id)');
        $this->addSql('ALTER TABLE user_history ADD CONSTRAINT FK_7FB76E4198771930 FOREIGN KEY (related_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('DROP SEQUENCE user_history_id_seq CASCADE');
        $this->addSql('ALTER TABLE user_history DROP CONSTRAINT FK_7FB76E4198771930');
        $this->addSql('DROP TABLE user_history');
    }
}
+32 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20240620121602 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE "user" ALTER patronymic DROP NOT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE "user" ALTER patronymic SET NOT NULL');
    }
}
+34 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace App\Controller;

use App\Service\Action\ActionServiceInterface;
use App\Service\Dto\Classes\ChangeProfileDto;
use App\Service\Dto\Classes\RecoveryCodeDto;
use App\Service\Dto\Classes\RecoveryDto;
use App\Service\Response\Classes\ProfileResponse;
@@ -82,4 +83,37 @@ class ProfileController extends AbstractController
    {
        return $checkRecoveryService->getResponse();
    }

    #[Route('/profile/change', name: 'profile_change', methods: ['POST'])]
    #[OA\RequestBody(
        content: new OA\JsonContent(ref: new Model(type: ChangeProfileDto::class))
    )]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: ProfileResponse::class, groups: ["message", "data", "profile"])
        )
    )]
    public function changeProfile(
        ActionServiceInterface $profileChangeService,
    ): JsonResponse
    {
        return $profileChangeService->getResponse();
    }

    #[Route('/profile/reset/email', name: 'profile_reset_email', methods: ['GET'])]
    #[OA\Response(
        response: 200,
        description: 'Ответ',
        content: new OA\JsonContent(
            ref: new Model(type: Response::class, groups: ["message"])
        )
    )]
    public function resetLastConfirmEmail(
        ActionServiceInterface $resetEmailService,
    ): JsonResponse
    {
        return $resetEmailService->getResponse();
    }
}
Loading