-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Account.php
204 lines (189 loc) · 6.16 KB
/
Account.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
declare(strict_types=1);
/*
* UserFrosting Account Sprinkle (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/sprinkle-account
* @copyright Copyright (c) 2022 Alexander Weissman & Louis Charette
* @license https://github.com/userfrosting/sprinkle-account/blob/master/LICENSE.md (MIT License)
*/
namespace UserFrosting\Sprinkle\Account;
use UserFrosting\Event\EventListenerRecipe;
use UserFrosting\Sprinkle\Account\Bakery\BakeCommand;
use UserFrosting\Sprinkle\Account\Bakery\CreateAdminUser;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\ActivitiesTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\GroupsTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\PasswordResetsTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\PermissionRolesTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\PermissionsTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\PersistencesTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\RolesTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\RoleUsersTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v400\VerificationsTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v420\AddingForeignKeys;
use UserFrosting\Sprinkle\Account\Database\Migrations\v430\UpdateGroupsTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v430\UpdateUsersTable;
use UserFrosting\Sprinkle\Account\Database\Migrations\v500\UpdateUsersTable as V500UpdateUsersTable;
use UserFrosting\Sprinkle\Account\Database\Seeds\DefaultGroups;
use UserFrosting\Sprinkle\Account\Database\Seeds\DefaultPermissions;
use UserFrosting\Sprinkle\Account\Database\Seeds\DefaultRoles;
use UserFrosting\Sprinkle\Account\Event\UserAuthenticatedEvent;
use UserFrosting\Sprinkle\Account\Event\UserCreatedEvent;
use UserFrosting\Sprinkle\Account\Event\UserLoggedInEvent;
use UserFrosting\Sprinkle\Account\Event\UserLoggedOutEvent;
use UserFrosting\Sprinkle\Account\I18n\LocaleServicesProvider;
use UserFrosting\Sprinkle\Account\Listener\AssignDefaultGroups;
use UserFrosting\Sprinkle\Account\Listener\AssignDefaultRoles;
use UserFrosting\Sprinkle\Account\Listener\UpgradePassword;
use UserFrosting\Sprinkle\Account\Listener\UserLogoutActivity;
use UserFrosting\Sprinkle\Account\Listener\UserSignInActivity;
use UserFrosting\Sprinkle\Account\Routes\AuthRoutes;
use UserFrosting\Sprinkle\Account\ServicesProvider\AuthService;
use UserFrosting\Sprinkle\Account\ServicesProvider\ErrorHandlerService;
use UserFrosting\Sprinkle\Account\ServicesProvider\ModelsService;
use UserFrosting\Sprinkle\Account\ServicesProvider\UserActivityLoggerService;
use UserFrosting\Sprinkle\Account\Twig\AccountExtension;
use UserFrosting\Sprinkle\Core\Core;
use UserFrosting\Sprinkle\Core\Sprinkle\Recipe\MigrationRecipe;
use UserFrosting\Sprinkle\Core\Sprinkle\Recipe\SeedRecipe;
use UserFrosting\Sprinkle\Core\Sprinkle\Recipe\TwigExtensionRecipe;
use UserFrosting\Sprinkle\SprinkleRecipe;
class Account implements SprinkleRecipe, MigrationRecipe, SeedRecipe, EventListenerRecipe, TwigExtensionRecipe
{
/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'Account Sprinkle';
}
/**
* {@inheritdoc}
*/
public function getPath(): string
{
return __DIR__ . '/../';
}
/**
* {@inheritdoc}
*/
public function getBakeryCommands(): array
{
return [
// BakeCommand::class,
// CreateAdminUser::class,
];
}
/**
* {@inheritdoc}
*/
public function getSprinkles(): array
{
return [
Core::class,
];
}
/**
* Returns a list of routes definition in PHP files.
*
* @return string[]
*/
public function getRoutes(): array
{
return [
AuthRoutes::class,
];
}
/**
* Returns a list of all PHP-DI services/container definitions files.
*
* @return string[]
*/
public function getServices(): array
{
return [
// LocaleServicesProvider::class, // TODO
AuthService::class,
ModelsService::class,
ErrorHandlerService::class,
UserActivityLoggerService::class,
];
}
/**
* Returns a list of all Middlewares classes.
*
* @return \Psr\Http\Server\MiddlewareInterface[]
*/
public function getMiddlewares(): array
{
return [];
}
/**
* {@inheritDoc}
*/
public function getMigrations(): array
{
return [
// v400
ActivitiesTable::class,
GroupsTable::class,
PasswordResetsTable::class,
PermissionRolesTable::class,
RolesTable::class,
PermissionsTable::class,
PersistencesTable::class,
RoleUsersTable::class,
UsersTable::class,
// v420
VerificationsTable::class,
AddingForeignKeys::class,
// v430
UpdateGroupsTable::class,
UpdateUsersTable::class,
// v500
V500UpdateUsersTable::class,
];
}
/**
* {@inheritDoc}
*/
public function getSeeds(): array
{
return [
DefaultGroups::class,
DefaultPermissions::class,
DefaultRoles::class,
];
}
/**
* {@inheritDoc}
*/
public function getEventListeners(): array
{
return [
UserCreatedEvent::class => [
AssignDefaultRoles::class,
AssignDefaultGroups::class,
],
UserLoggedInEvent::class => [
UserSignInActivity::class,
],
UserLoggedOutEvent::class => [
UserLogoutActivity::class,
],
UserAuthenticatedEvent::class => [
UpgradePassword::class,
],
];
}
/**
* {@inheritDoc}
*/
public function getTwigExtensions(): array
{
return [
AccountExtension::class,
];
}
}