generator-folklore 3.0.9 → 3.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/generators/laravel-panneau/templates/app/Http/Middleware/Authenticate.php +1 -1
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +1 -3
- package/lib/generators/laravel-panneau/templates/app/Panneau/Composers/AppComposer.php +2 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php +3 -1
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +5 -5
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/ParentPageResource.php +43 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Block.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/ImageBlock.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +2 -2
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/PasswordValidationRules.php +18 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Responses/LoginResponse.php +27 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Responses/LoginViewResponse.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/FortifyServiceProvider.php +54 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/assets/.gitignore +2 -0
- package/package.json +2 -2
@@ -30,9 +30,7 @@ class PageResource extends JsonResource
|
|
30
30
|
'slug' => $this->slug($locale),
|
31
31
|
'image' => !is_null($image) ? new MediaResource($image) : null,
|
32
32
|
'parent' =>
|
33
|
-
!is_null($parent) && $parent instanceof Page
|
34
|
-
? new PageResource($parent)
|
35
|
-
: null,
|
33
|
+
!is_null($parent) && $parent instanceof Page ? new PageResource($parent) : null,
|
36
34
|
|
37
35
|
$this->mergeWhen($this->resource instanceof HasBlocks, function () {
|
38
36
|
$blocks = $this->blocks();
|
@@ -42,6 +42,8 @@ class AppComposer
|
|
42
42
|
'user' => !is_null($user) ? new UserResource($user) : null,
|
43
43
|
'isPanneau' => true,
|
44
44
|
'statusCode' => $view->statusCode,
|
45
|
+
'baseUrl' => config('app.url'),
|
46
|
+
'tusUrl' => null,
|
45
47
|
'pubnubNamespace' => config('services.pubnub.namespace'),
|
46
48
|
'pubnubPublishKey' => config('services.pubnub.publish_key'),
|
47
49
|
'pubnubSubscribeKey' => config('services.pubnub.subscribe_key'),
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php
CHANGED
@@ -4,10 +4,12 @@ namespace App\Panneau\Http\Controllers;
|
|
4
4
|
|
5
5
|
use App\Panneau\Http\Requests\UploadRequest;
|
6
6
|
use Folklore\Contracts\Repositories\Medias as MediasRepository;
|
7
|
-
use Folklore\Http\Resources\
|
7
|
+
use Folklore\Http\Resources\MediaResource;
|
8
8
|
|
9
9
|
class UploadController extends Controller
|
10
10
|
{
|
11
|
+
protected $medias;
|
12
|
+
|
11
13
|
public function __construct(MediasRepository $medias)
|
12
14
|
{
|
13
15
|
$this->medias = $medias;
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
namespace App\Panneau\Http\Resources;
|
4
4
|
|
5
5
|
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
-
use
|
6
|
+
use Folklore\Http\Resources\MediaResource;
|
7
7
|
use App\Contracts\Resources\Page;
|
8
|
-
use
|
8
|
+
use Folklore\Contracts\Resources\HasBlocks;
|
9
9
|
use Folklore\Http\Resources\LocalizedResource;
|
10
10
|
use App\Contracts\Resources\Pages\Home as HomePage;
|
11
11
|
|
@@ -19,8 +19,8 @@ class PageResource extends JsonResource
|
|
19
19
|
*/
|
20
20
|
public function toArray($request)
|
21
21
|
{
|
22
|
-
$
|
23
|
-
$
|
22
|
+
$image = $this->image();
|
23
|
+
$parent = $this->parent();
|
24
24
|
|
25
25
|
return [
|
26
26
|
'id' => $this->id(),
|
@@ -35,7 +35,7 @@ class PageResource extends JsonResource
|
|
35
35
|
'slug' => new LocalizedResource(function ($locale) {
|
36
36
|
return $this->slug($locale);
|
37
37
|
}),
|
38
|
-
'image' => !is_null($image) ? new
|
38
|
+
'image' => !is_null($image) ? new MediaResource($image) : null,
|
39
39
|
'parent' =>
|
40
40
|
!is_null($parent) && $parent instanceof Page
|
41
41
|
? new ParentPageResource($parent)
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/ParentPageResource.php
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
use Folklore\Http\Resources\MediaResource;
|
7
|
+
use App\Contracts\Resources\Page;
|
8
|
+
use Folklore\Http\Resources\LocalizedResource;
|
9
|
+
|
10
|
+
class ParentPageResource extends JsonResource
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Transform the resource into an array.
|
14
|
+
*
|
15
|
+
* @param \Illuminate\Http\Request $request
|
16
|
+
* @return array
|
17
|
+
*/
|
18
|
+
public function toArray($request)
|
19
|
+
{
|
20
|
+
$image = $this->image();
|
21
|
+
$parent = $this->parent();
|
22
|
+
|
23
|
+
return [
|
24
|
+
'id' => $this->id(),
|
25
|
+
'type' => $this->type(),
|
26
|
+
'published' => $this->published(),
|
27
|
+
'title' => new LocalizedResource(function ($locale) {
|
28
|
+
return $this->title($locale);
|
29
|
+
}),
|
30
|
+
'description' => new LocalizedResource(function ($locale) {
|
31
|
+
return $this->description($locale);
|
32
|
+
}),
|
33
|
+
'slug' => new LocalizedResource(function ($locale) {
|
34
|
+
return $this->slug($locale);
|
35
|
+
}),
|
36
|
+
'image' => !is_null($image) ? new MediaResource($image) : null,
|
37
|
+
'parent' =>
|
38
|
+
!is_null($parent) && $parent instanceof Page
|
39
|
+
? new ParentPageResource($parent)
|
40
|
+
: null,
|
41
|
+
];
|
42
|
+
}
|
43
|
+
}
|
@@ -3,11 +3,11 @@
|
|
3
3
|
namespace App\Resources\Blocks;
|
4
4
|
|
5
5
|
use App\Resources\Block;
|
6
|
-
use App\Contracts\Resources\Blocks\
|
6
|
+
use App\Contracts\Resources\Blocks\Image as ImageBlockContract;
|
7
7
|
use Folklore\Contracts\Resources\Image as ImageContract;
|
8
8
|
use Folklore\Resources\Image;
|
9
9
|
|
10
|
-
class ImageBlock extends Block implements
|
10
|
+
class ImageBlock extends Block implements ImageBlockContract
|
11
11
|
{
|
12
12
|
public function image(): ?ImageContract
|
13
13
|
{
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Actions\Fortify;
|
4
|
+
|
5
|
+
use Laravel\Fortify\Rules\Password;
|
6
|
+
|
7
|
+
trait PasswordValidationRules
|
8
|
+
{
|
9
|
+
/**
|
10
|
+
* Get the validation rules used to validate passwords.
|
11
|
+
*
|
12
|
+
* @return array
|
13
|
+
*/
|
14
|
+
protected function passwordRules()
|
15
|
+
{
|
16
|
+
return ['required', 'string', new Password, 'confirmed'];
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Http\Responses;
|
4
|
+
|
5
|
+
use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract;
|
6
|
+
use Laravel\Fortify\Fortify;
|
7
|
+
use App\Http\Resources\UserResource;
|
8
|
+
use App\Panneau\Http\Resources\UserResource as PanneauUserResource;
|
9
|
+
|
10
|
+
class LoginResponse implements LoginResponseContract
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Create an HTTP response that represents the object.
|
14
|
+
*
|
15
|
+
* @param \Illuminate\Http\Request $request
|
16
|
+
* @return \Symfony\Component\HttpFoundation\Response
|
17
|
+
*/
|
18
|
+
public function toResponse($request)
|
19
|
+
{
|
20
|
+
if ($request->wantsJson()) {
|
21
|
+
return $request->isPanneau()
|
22
|
+
? new PanneauUserResource($request->user())
|
23
|
+
: new UserResource($request->participant());
|
24
|
+
}
|
25
|
+
return redirect()->intended(Fortify::redirects('login'));
|
26
|
+
}
|
27
|
+
}
|
package/lib/generators/laravel-project/templates/laravel/app/Http/Responses/LoginViewResponse.php
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Http\Responses;
|
4
|
+
|
5
|
+
use Laravel\Fortify\Contracts\LoginViewResponse as LoginViewResponseContract;
|
6
|
+
|
7
|
+
class LoginViewResponse implements LoginViewResponseContract
|
8
|
+
{
|
9
|
+
/**
|
10
|
+
* Create an HTTP response that represents the object.
|
11
|
+
*
|
12
|
+
* @param \Illuminate\Http\Request $request
|
13
|
+
* @return \Symfony\Component\HttpFoundation\Response
|
14
|
+
*/
|
15
|
+
public function toResponse($request)
|
16
|
+
{
|
17
|
+
return $request->isPanneau() ? view('panneau::app') : view('app');
|
18
|
+
}
|
19
|
+
}
|
package/lib/generators/laravel-project/templates/laravel/app/Providers/FortifyServiceProvider.php
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Providers;
|
4
|
+
|
5
|
+
use App\Actions\Fortify\CreateNewUser;
|
6
|
+
use App\Actions\Fortify\ResetUserPassword;
|
7
|
+
use App\Actions\Fortify\UpdateUserPassword;
|
8
|
+
use App\Actions\Fortify\UpdateUserProfileInformation;
|
9
|
+
use App\Http\Responses\LoginResponse;
|
10
|
+
use App\Http\Responses\LoginViewResponse;
|
11
|
+
use Illuminate\Cache\RateLimiting\Limit;
|
12
|
+
use Illuminate\Http\Request;
|
13
|
+
use Illuminate\Support\Facades\RateLimiter;
|
14
|
+
use Illuminate\Support\ServiceProvider;
|
15
|
+
use Laravel\Fortify\Fortify;
|
16
|
+
use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract;
|
17
|
+
use Laravel\Fortify\Contracts\LoginViewResponse as LoginViewResponseContract;
|
18
|
+
|
19
|
+
class FortifyServiceProvider extends ServiceProvider
|
20
|
+
{
|
21
|
+
/**
|
22
|
+
* Register any application services.
|
23
|
+
*
|
24
|
+
* @return void
|
25
|
+
*/
|
26
|
+
public function register()
|
27
|
+
{
|
28
|
+
$this->app->bind(LoginResponseContract::class, LoginResponse::class);
|
29
|
+
$this->app->bind(LoginViewResponseContract::class, LoginViewResponse::class);
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Bootstrap any application services.
|
34
|
+
*
|
35
|
+
* @return void
|
36
|
+
*/
|
37
|
+
public function boot()
|
38
|
+
{
|
39
|
+
Fortify::createUsersUsing(CreateNewUser::class);
|
40
|
+
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
|
41
|
+
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
|
42
|
+
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
|
43
|
+
|
44
|
+
RateLimiter::for('login', function (Request $request) {
|
45
|
+
$email = (string) $request->email;
|
46
|
+
|
47
|
+
return Limit::perMinute(5)->by($email . $request->ip());
|
48
|
+
});
|
49
|
+
|
50
|
+
RateLimiter::for('two-factor', function (Request $request) {
|
51
|
+
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "generator-folklore",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.11",
|
4
4
|
"description": "Yeoman generator for projects at Folklore",
|
5
5
|
"keywords": [
|
6
6
|
"yeoman-generator"
|
@@ -40,5 +40,5 @@
|
|
40
40
|
"yeoman-generator": "^5.7.0",
|
41
41
|
"yeoman-remote": "^1.0.1"
|
42
42
|
},
|
43
|
-
"gitHead": "
|
43
|
+
"gitHead": "61748b478ab945f855a51499efb51c0cbcf3d880"
|
44
44
|
}
|