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.
@@ -16,7 +16,7 @@ class Authenticate extends Middleware
16
16
  {
17
17
  if (!$request->expectsJson()) {
18
18
  $routeWithLocale =
19
- route_with_locale('login') .
19
+ route('panneau.auth.login') .
20
20
  '?' .
21
21
  http_build_query([
22
22
  'next' => $request->fullUrl(),
@@ -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'),
@@ -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\Medias\MediaResource;
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;
@@ -3,9 +3,9 @@
3
3
  namespace App\Panneau\Http\Resources;
4
4
 
5
5
  use Illuminate\Http\Resources\Json\JsonResource;
6
- use App\Http\Resources\Medias\ImageResource;
6
+ use Folklore\Http\Resources\MediaResource;
7
7
  use App\Contracts\Resources\Page;
8
- use App\Contracts\Resources\HasBlocks;
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
- $locale = $request->locale();
23
- $isPanneauIndex = $request->isPanneauIndex();
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 ImageResource($image) : null,
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)
@@ -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,8 +3,8 @@
3
3
  namespace App\Resources;
4
4
 
5
5
  use Folklore\Resources\Block as BaseBlock;
6
+ use App\Contracts\Resources\Block as BlockContract;
6
7
 
7
- class Block extends BaseBlock
8
+ class Block extends BaseBlock implements BlockContract
8
9
  {
9
-
10
10
  }
@@ -3,11 +3,11 @@
3
3
  namespace App\Resources\Blocks;
4
4
 
5
5
  use App\Resources\Block;
6
- use App\Contracts\Resources\Blocks\Text as TextBlockContract;
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 TextBlockContract
10
+ class ImageBlock extends Block implements ImageBlockContract
11
11
  {
12
12
  public function image(): ?ImageContract
13
13
  {
@@ -3,8 +3,8 @@
3
3
  namespace App\Resources;
4
4
 
5
5
  use Folklore\Resources\Page as BasePage;
6
+ use App\Contracts\Resources\Page as PageContract;
6
7
 
7
- class Page extends BasePage
8
+ class Page extends BasePage implements PageContract
8
9
  {
9
-
10
10
  }
@@ -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
+ }
@@ -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
+ }
@@ -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.9",
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": "88e0fd31cded9ff974e5b50f4c76464ef26efb12"
43
+ "gitHead": "61748b478ab945f855a51499efb51c0cbcf3d880"
44
44
  }