-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathResetPassword.php
67 lines (61 loc) · 2.24 KB
/
ResetPassword.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace App\DTO;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
use App\InputFilter;
use App\State\ResetPasswordCreateProcessor;
use App\State\ResetPasswordProvider;
use App\State\ResetPasswordUpdateProcessor;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource(
operations: [
new Get(
provider: ResetPasswordProvider::class,
uriTemplate: '/reset_password/{id}{._format}', // TO DISCUSS: default uri would be /reset_password (plural). Shall we keep or fix?
security: 'true',
),
new Patch(
provider: ResetPasswordProvider::class,
processor: ResetPasswordUpdateProcessor::class,
uriTemplate: '/reset_password/{id}{._format}',
security: 'true',
denormalizationContext: ['groups' => ['update']]
),
new Post(
processor: ResetPasswordCreateProcessor::class,
uriTemplate: '/reset_password{._format}',
security: 'true',
status: 204,
output: false,
denormalizationContext: ['groups' => ['create']],
normalizationContext: ['groups' => ['read']],
openapi: new OpenApiOperation(summary: 'Request Password-Reset-Mail', description: 'Password-Reset-Link will be sent to the given email')
),
],
routePrefix: '/auth'
)]
class ResetPassword {
/**
* $id: base64_encode($email . '#' . $resetKey).
*/
#[ApiProperty(readable: true, writable: false, identifier: true)]
#[Groups(['read'])]
public ?string $id = null;
#[InputFilter\Trim]
#[InputFilter\Lowercase]
#[ApiProperty(readable: true, writable: true)]
#[Groups(['create', 'read'])]
public ?string $email = null;
#[ApiProperty(readable: false, writable: true)]
#[Groups(['create', 'update'])]
public ?string $recaptchaToken = null;
#[ApiProperty(readable: false, writable: true)]
#[Groups(['update'])]
#[Assert\Length(min: 12, max: 128)]
public ?string $password = null;
}