2f3fd laravel 11 upgrade (#436)

* fix password reset bug

* upgrade to  laravel 11

* composer.lock

* fix migration issues

* use ValidationRule Contract

* rename password_resets table

* implemented casts as protected function

* update env variables

* fix optional property

* fix validation issues

* use <env> on php unit xml

* fix pint

* cmposer.lock

* composer json fixes

* fix composer dependencies, remove  faker

* remove unused class

* remove test class

* fix default value for mysql migration

* linting

* expression syntax fix

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka 2024-06-10 15:10:14 +01:00 committed by GitHub
parent 1875faa123
commit bec8e86b59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 2078 additions and 3158 deletions

View File

@ -18,8 +18,8 @@ DB_PASSWORD=postgres
FILESYSTEM_DRIVER=s3 FILESYSTEM_DRIVER=s3
FILESYSTEM_DISK=s3 FILESYSTEM_DISK=s3
BROADCAST_DRIVER=log BROADCAST_CONNECTION=log
CACHE_DRIVER=redis CACHE_STORE=redis
QUEUE_CONNECTION=redis QUEUE_CONNECTION=redis
SESSION_DRIVER=file SESSION_DRIVER=file
SESSION_LIFETIME=120 SESSION_LIFETIME=120

View File

@ -21,8 +21,8 @@ DB_PASSWORD=postgres
FILESYSTEM_DRIVER=s3 FILESYSTEM_DRIVER=s3
FILESYSTEM_DISK=s3 FILESYSTEM_DISK=s3
BROADCAST_DRIVER=log BROADCAST_CONNECTION=log
CACHE_DRIVER=file CACHE_STORE=file
QUEUE_CONNECTION=sync QUEUE_CONNECTION=sync
SESSION_DRIVER=file SESSION_DRIVER=file
SESSION_LIFETIME=120 SESSION_LIFETIME=120

View File

@ -89,7 +89,9 @@ class Form extends Model implements CachableAttributes
'seo_meta', 'seo_meta',
]; ];
protected $casts = [ protected function casts(): array
{
return [
'properties' => 'array', 'properties' => 'array',
'database_fields_update' => 'array', 'database_fields_update' => 'array',
'closes_at' => 'datetime', 'closes_at' => 'datetime',
@ -97,6 +99,7 @@ class Form extends Model implements CachableAttributes
'removed_properties' => 'array', 'removed_properties' => 'array',
'seo_meta' => 'object' 'seo_meta' => 'object'
]; ];
}
protected $appends = [ protected $appends = [
'share_url', 'share_url',
@ -129,7 +132,7 @@ class Form extends Model implements CachableAttributes
public function getIsProAttribute() public function getIsProAttribute()
{ {
return $this->remember('is_pro', 15 * 60, function (): ?bool { return $this->remember('is_pro', 15 * 60, function (): ?bool {
return optional($this->workspace)->is_pro === true; return $this->workspace?->is_pro === true;
}); });
} }

View File

@ -22,9 +22,12 @@ class FormStatistic extends Model
* *
* @var array * @var array
*/ */
protected $casts = [ protected function casts(): array
{
return [
'data' => 'array', 'data' => 'array',
]; ];
}
/** /**
* Relationships * Relationships

View File

@ -13,9 +13,12 @@ class FormSubmission extends Model
'data', 'data',
]; ];
protected $casts = [ protected function casts(): array
{
return [
'data' => 'array', 'data' => 'array',
]; ];
}
/** /**
* RelationShips * RelationShips

View File

@ -23,10 +23,13 @@ class FormIntegration extends Model
'oauth_id' 'oauth_id'
]; ];
protected $casts = [ protected function casts(): array
{
return [
'data' => 'object', 'data' => 'object',
'logic' => 'object' 'logic' => 'object'
]; ];
}
protected $dispatchesEvents = [ protected $dispatchesEvents = [
'created' => FormIntegrationCreated::class, 'created' => FormIntegrationCreated::class,

View File

@ -19,9 +19,12 @@ class FormIntegrationsEvent extends Model
'data' 'data'
]; ];
protected $casts = [ protected function casts()
{
return [
'data' => 'object' 'data' => 'object'
]; ];
}
/** /**
* The event map for the model. * The event map for the model.

View File

@ -20,9 +20,12 @@ class License extends Model
'meta', 'meta',
]; ];
protected $casts = [ protected function casts()
{
return [
'meta' => 'array', 'meta' => 'array',
]; ];
}
public function user() public function user()
{ {

View File

@ -29,7 +29,9 @@ class Template extends Model
'related_templates', 'related_templates',
]; ];
protected $casts = [ protected function casts()
{
return [
'structure' => 'array', 'structure' => 'array',
'questions' => 'array', 'questions' => 'array',
'industries' => 'array', 'industries' => 'array',
@ -38,6 +40,7 @@ class Template extends Model
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
}
protected $attributes = [ protected $attributes = [
'publicly_listed' => false, 'publicly_listed' => false,

View File

@ -45,9 +45,12 @@ class User extends Authenticatable implements JWTSubject
* *
* @var array * @var array
*/ */
protected $casts = [ protected function casts()
{
return [
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
}
/** /**
* The accessors to append to the model's array form. * The accessors to append to the model's array form.

View File

@ -32,9 +32,12 @@ class Workspace extends Model implements CachableAttributes
'is_enterprise', 'is_enterprise',
]; ];
protected $casts = [ protected function casts()
{
return [
'custom_domains' => 'array', 'custom_domains' => 'array',
]; ];
}
protected $cachableAttributes = [ protected $cachableAttributes = [
'is_pro', 'is_pro',

View File

@ -36,8 +36,6 @@ class AuthServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
$this->registerPolicies();
\Illuminate\Support\Facades\Gate::define('viewMailcoach', function ($user = null) { \Illuminate\Support\Facades\Gate::define('viewMailcoach', function ($user = null) {
return optional($user)->admin; return optional($user)->admin;
}); });

View File

@ -1,24 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Jhumanj\LaravelModelStats\LaravelModelStats;
use Jhumanj\LaravelModelStats\ModelStatsServiceProvider as Provider;
class ModelStatsServiceProvider extends Provider
{
/**
* Register the LaravelModelStats gate.
*
* This gate determines who can access ModelStats in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewModelStats', function ($user) {
return in_array($user->email, [
'julien@notionforms.io',
]);
});
}
}

View File

@ -44,7 +44,7 @@ class RouteServiceProvider extends ServiceProvider
protected function configureRateLimiting() protected function configureRateLimiting()
{ {
RateLimiter::for('api', function (Request $request) { RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
}); });
} }

View File

@ -3,9 +3,10 @@
namespace App\Rules; namespace App\Rules;
use App\Service\Forms\FormLogicConditionChecker; use App\Service\Forms\FormLogicConditionChecker;
use Illuminate\Contracts\Validation\Rule; use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class CustomFieldValidationRule implements Rule class CustomFieldValidationRule implements ValidationRule
{ {
/** /**
* Create a new rule instance. * Create a new rule instance.
@ -36,6 +37,13 @@ class CustomFieldValidationRule implements Rule
); );
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.
* *

View File

@ -2,11 +2,12 @@
namespace App\Rules; namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\DataAwareRule; use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Contracts\Validation\Rule; use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class FormPropertyLogicRule implements DataAwareRule, Rule class FormPropertyLogicRule implements DataAwareRule, ValidationRule
{ {
public const ACTIONS_VALUES = [ public const ACTIONS_VALUES = [
'show-block', 'show-block',
@ -803,6 +804,13 @@ class FormPropertyLogicRule implements DataAwareRule, Rule
return $this->isConditionCorrect && $this->isActionCorrect; return $this->isConditionCorrect && $this->isActionCorrect;
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.
*/ */

View File

@ -2,10 +2,11 @@
namespace App\Rules; namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\DataAwareRule; use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Contracts\Validation\Rule; use Illuminate\Contracts\Validation\ValidationRule;
class IntegrationLogicRule implements DataAwareRule, Rule class IntegrationLogicRule implements DataAwareRule, ValidationRule
{ {
private $isConditionCorrect = true; private $isConditionCorrect = true;
@ -153,6 +154,13 @@ class IntegrationLogicRule implements DataAwareRule, Rule
return $this->isConditionCorrect; return $this->isConditionCorrect;
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.
*/ */

View File

@ -2,9 +2,10 @@
namespace App\Rules; namespace App\Rules;
use Illuminate\Contracts\Validation\Rule; use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class OneEmailPerLine implements Rule class OneEmailPerLine implements ValidationRule
{ {
/** /**
* Create a new rule instance. * Create a new rule instance.
@ -38,6 +39,13 @@ class OneEmailPerLine implements Rule
return true; return true;
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.
* *

View File

@ -5,11 +5,12 @@ namespace App\Rules;
use App\Http\Controllers\Forms\PublicFormController; use App\Http\Controllers\Forms\PublicFormController;
use App\Models\Forms\Form; use App\Models\Forms\Form;
use App\Service\Storage\StorageFileNameParser; use App\Service\Storage\StorageFileNameParser;
use Illuminate\Contracts\Validation\Rule; use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class StorageFile implements Rule class StorageFile implements ValidationRule
{ {
public string $error = 'Invalid file.'; public string $error = 'Invalid file.';
@ -66,6 +67,13 @@ class StorageFile implements Rule
return true; return true;
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
public function message(): string public function message(): string
{ {
return $this->error; return $this->error;

View File

@ -2,6 +2,7 @@
namespace App\Rules; namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ImplicitRule; use Illuminate\Contracts\Validation\ImplicitRule;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
@ -31,6 +32,12 @@ class ValidHCaptcha implements ImplicitRule
'response' => $value, 'response' => $value,
])->json('success'); ])->json('success');
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.

View File

@ -2,9 +2,10 @@
namespace App\Rules; namespace App\Rules;
use Illuminate\Contracts\Validation\Rule; use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class ValidPhoneInputRule implements Rule class ValidPhoneInputRule implements ValidationRule
{ {
public ?int $reason = 0; public ?int $reason = 0;
@ -27,6 +28,13 @@ class ValidPhoneInputRule implements Rule
} }
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
public function message() public function message()
{ {
return match ($this->reason) { return match ($this->reason) {

View File

@ -2,9 +2,10 @@
namespace App\Rules; namespace App\Rules;
use Illuminate\Contracts\Validation\Rule; use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class ValidUrl implements Rule class ValidUrl implements ValidationRule
{ {
/** /**
* Determine if the validation rule passes. * Determine if the validation rule passes.
@ -21,6 +22,13 @@ class ValidUrl implements Rule
return preg_match($pattern, $value); return preg_match($pattern, $value);
} }
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail($this->message());
}
}
/** /**
* Get the validation error message. * Get the validation error message.
* *

View File

@ -14,48 +14,42 @@
"require": { "require": {
"php": "^8.2", "php": "^8.2",
"ext-json": "*", "ext-json": "*",
"aws/aws-sdk-php": "^3.183", "aws/aws-sdk-php": "*",
"doctrine/dbal": "^3.4", "doctrine/dbal": "*",
"giggsey/libphonenumber-for-php": "^8.13", "giggsey/libphonenumber-for-php": "*",
"google/apiclient": "^2.15.0", "google/apiclient": "^2.16",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "*",
"jhumanj/laravel-model-stats": "^0.4.0", "laravel/cashier": "*",
"laravel/cashier": "^13.4", "laravel/framework": "^11.9",
"laravel/framework": "^9.19.0", "laravel/horizon": "*",
"laravel/horizon": "^5.7", "laravel/socialite": "*",
"laravel/socialite": "^5.2", "laravel/tinker": "^2.9",
"laravel/tinker": "^2.6", "laravel/ui": "*",
"laravel/ui": "^3.2", "laravel/vapor-cli": "*",
"laravel/vapor-cli": "^1.38", "laravel/vapor-core": "*",
"laravel/vapor-core": "^2.21", "league/flysystem-aws-s3-v3": "*",
"laravel/vapor-ui": "^1.5",
"league/flysystem-aws-s3-v3": "^3.0",
"maatwebsite/excel": "^3.1", "maatwebsite/excel": "^3.1",
"openai-php/client": "^0.6.4", "openai-php/client": "*",
"propaganistas/laravel-disposable-email": "^2.2", "propaganistas/laravel-disposable-email": "*",
"sentry/sentry-laravel": "^2.11.0", "sentry/sentry-laravel": "*",
"spatie/laravel-data": "^3.12", "spatie/laravel-data": "^4.6",
"spatie/laravel-sitemap": "^6.0", "spatie/laravel-sitemap": "*",
"spatie/laravel-sluggable": "^3.0", "spatie/laravel-sluggable": "*",
"stevebauman/purify": "^v6.2.0", "stevebauman/purify": "*",
"tymon/jwt-auth": "^1.0.2", "tymon/jwt-auth": "*",
"vinkla/hashids": "^10.0" "vinkla/hashids": "*"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-ide-helper": "^2.12", "barryvdh/laravel-ide-helper": "^3.0.0",
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.23",
"laravel/dusk": "^6.8", "laravel/dusk": "^8.2.0",
"laravel/pint": "^1.14", "laravel/pint": "^1.13",
"laravel/sail": "^1.18", "laravel/sail": "^1.26",
"mockery/mockery": "^1.4.2", "mockery/mockery": "^1.6",
"nunomaduro/collision": "^6.1", "nunomaduro/collision": "*",
"pestphp/pest": "^1.15", "pestphp/pest": "^2.0",
"pestphp/pest-plugin-faker": "^1.0", "spatie/laravel-ignition": "*",
"pestphp/pest-plugin-laravel": "^1.1", "spatie/laravel-ray": "*"
"pestphp/pest-plugin-parallel": "^1.2",
"phpunit/phpunit": "^9.3.3",
"spatie/laravel-ignition": "^1.0",
"spatie/laravel-ray": "^1.17"
}, },
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,
@ -111,7 +105,7 @@
"@php artisan jwt:secret --force --ansi" "@php artisan jwt:secret --force --ansi"
], ],
"post-update-cmd": [ "post-update-cmd": [
"@php artisan vapor-ui:publish --ansi" "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
] ]
} }
} }

4254
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -185,7 +185,6 @@ return [
App\Providers\HorizonServiceProvider::class, App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\VaporUiServiceProvider::class, App\Providers\VaporUiServiceProvider::class,
App\Providers\ModelStatsServiceProvider::class,
App\Providers\PurifySetupProvider::class, App\Providers\PurifySetupProvider::class,
/* /*

View File

@ -95,7 +95,7 @@ return [
'passwords' => [ 'passwords' => [
'users' => [ 'users' => [
'provider' => 'users', 'provider' => 'users',
'table' => 'password_resets', 'table' => 'password_reset_tokens',
'expire' => 60, 'expire' => 60,
'throttle' => 60, 'throttle' => 60,
], ],

301
config/jwt.php Normal file
View File

@ -0,0 +1,301 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
/*
|--------------------------------------------------------------------------
| JWT Authentication Secret
|--------------------------------------------------------------------------
|
| Don't forget to set this in your .env file, as it will be used to sign
| your tokens. A helper command is provided for this:
| `php artisan jwt:secret`
|
| Note: This will be used for Symmetric algorithms only (HMAC),
| since RSA and ECDSA use a private/public key combo (See below).
|
*/
'secret' => env('JWT_SECRET'),
/*
|--------------------------------------------------------------------------
| JWT Authentication Keys
|--------------------------------------------------------------------------
|
| The algorithm you are using, will determine whether your tokens are
| signed with a random string (defined in `JWT_SECRET`) or using the
| following public & private keys.
|
| Symmetric Algorithms:
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
| Asymmetric Algorithms:
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
*/
'keys' => [
/*
|--------------------------------------------------------------------------
| Public Key
|--------------------------------------------------------------------------
|
| A path or resource to your public key.
|
| E.g. 'file://path/to/public/key'
|
*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| A path or resource to your private key.
|
| E.g. 'file://path/to/private/key'
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
],
/*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour.
|
| You can also set this to null, to yield a never expiring token.
| Some people may want this behaviour for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
|
*/
'ttl' => (int) env('JWT_TTL', 60),
/*
|--------------------------------------------------------------------------
| Refresh time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate.
| Defaults to 2 weeks.
|
| You can also set this to null, to yield an infinite refresh time.
| Some may want this instead of never expiring tokens for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
|
*/
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
/*
|--------------------------------------------------------------------------
| JWT hashing algorithm
|--------------------------------------------------------------------------
|
| Specify the hashing algorithm that will be used to sign the token.
|
*/
'algo' => env('JWT_ALGO', Tymon\JWTAuth\Providers\JWT\Provider::ALGO_HS256),
/*
|--------------------------------------------------------------------------
| Required Claims
|--------------------------------------------------------------------------
|
| Specify the required claims that must exist in any token.
| A TokenInvalidException will be thrown if any of these claims are not
| present in the payload.
|
*/
'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
/*
|--------------------------------------------------------------------------
| Persistent Claims
|--------------------------------------------------------------------------
|
| Specify the claim keys to be persisted when refreshing a token.
| `sub` and `iat` will automatically be persisted, in
| addition to the these claims.
|
| Note: If a claim does not exist then it will be ignored.
|
*/
'persistent_claims' => [
// 'foo',
// 'bar',
],
/*
|--------------------------------------------------------------------------
| Lock Subject
|--------------------------------------------------------------------------
|
| This will determine whether a `prv` claim is automatically added to
| the token. The purpose of this is to ensure that if you have multiple
| authentication models e.g. `App\User` & `App\OtherPerson`, then we
| should prevent one authentication request from impersonating another,
| if 2 tokens happen to have the same id across the 2 different models.
|
| Under specific circumstances, you may want to disable this behaviour
| e.g. if you only have one authentication model, then you would save
| a little on token size.
|
*/
'lock_subject' => true,
/*
|--------------------------------------------------------------------------
| Leeway
|--------------------------------------------------------------------------
|
| This property gives the jwt timestamp claims some "leeway".
| Meaning that if you have any unavoidable slight clock skew on
| any of your servers then this will afford you some level of cushioning.
|
| This applies to the claims `iat`, `nbf` and `exp`.
|
| Specify in seconds - only if you know you need it.
|
*/
'leeway' => env('JWT_LEEWAY', 0),
/*
|--------------------------------------------------------------------------
| Blacklist Enabled
|--------------------------------------------------------------------------
|
| In order to invalidate tokens, you must have the blacklist enabled.
| If you do not want or need this functionality, then set this to false.
|
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| When multiple concurrent requests are made with the same JWT,
| it is possible that some of them fail, due to token regeneration
| on every request.
|
| Set grace period in seconds to prevent parallel request failure.
|
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/*
|--------------------------------------------------------------------------
| Cookies encryption
|--------------------------------------------------------------------------
|
| By default Laravel encrypt cookies for security reason.
| If you decide to not decrypt cookies, you will have to configure Laravel
| to not encrypt your cookie token by adding its name into the $except
| array available in the middleware "EncryptCookies" provided by Laravel.
| see https://laravel.com/docs/master/responses#cookies-and-encryption
| for details.
|
| Set it to true if you want to decrypt cookies.
|
*/
'decrypt_cookies' => false,
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
| Specify the various providers used throughout the package.
|
*/
'providers' => [
/*
|--------------------------------------------------------------------------
| JWT Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to create and decode the tokens.
|
*/
'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
/*
|--------------------------------------------------------------------------
| Authentication Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to authenticate users.
|
*/
'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
/*
|--------------------------------------------------------------------------
| Storage Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to store tokens in the blacklist.
|
*/
'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
],
];

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('stripe_id')->nullable()->index();
$table->string('pm_type')->nullable();
$table->string('pm_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'stripe_id',
'pm_type',
'pm_last_four',
'trial_ends_at',
]);
});
}
};

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->string('name');
$table->string('stripe_id')->unique();
$table->string('stripe_status');
$table->string('stripe_price')->nullable();
$table->integer('quantity')->nullable();
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'stripe_status']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subscriptions');
}
};

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscription_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('subscription_id');
$table->string('stripe_id')->unique();
$table->string('stripe_product');
$table->string('stripe_price');
$table->integer('quantity')->nullable();
$table->timestamps();
$table->unique(['subscription_id', 'stripe_price']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subscription_items');
}
};

View File

@ -1,8 +1,10 @@
<?php <?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class () extends Migration { return new class () extends Migration {
/** /**
@ -13,7 +15,12 @@ return new class () extends Migration {
public function up() public function up()
{ {
Schema::table('forms', function (Blueprint $table) { Schema::table('forms', function (Blueprint $table) {
$driver = DB::getDriverName();
if ($driver === 'mysql') {
$table->text('max_submissions_reached_text')->nullable()->default(new Expression("('This form has now reached the maximum number of allowed submissions and is now closed.')"))->change();
} else {
$table->text('max_submissions_reached_text')->nullable()->default('This form has now reached the maximum number of allowed submissions and is now closed.')->change(); $table->text('max_submissions_reached_text')->nullable()->default('This form has now reached the maximum number of allowed submissions and is now closed.')->change();
}
}); });
} }

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->renameColumn('name', 'type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->renameColumn('type', 'name');
});
}
};

View File

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::rename('password_resets', 'password_reset_tokens');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::rename('password_reset_tokens', 'password_resets');
}
};

View File

@ -15,23 +15,23 @@
<!-- <directory suffix="Test.php">./tests/Browser</directory>--> <!-- <directory suffix="Test.php">./tests/Browser</directory>-->
<!-- </testsuite>--> <!-- </testsuite>-->
</testsuites> </testsuites>
<coverage processUncoveredFiles="true"> <coverage>
<include> <include>
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include> </include>
</coverage> </coverage>
<php> <php>
<server name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/> <env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<server name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/> <env name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/> <env name="CACHE_DRIVER" value="array"/>
<server name="DB_FOREIGN_KEYS" value="(false)"/> <env name="DB_FOREIGN_KEYS" value="(false)"/>
<server name="MAIL_MAILER" value="log"/> <env name="MAIL_MAILER" value="log"/>
<server name="MAIL_FROM_ADDRESS" value="notifications@notionforms.io"/> <env name="MAIL_FROM_ADDRESS" value="notifications@notionforms.io"/>
<server name="MAIL_FROM_NAME" value="NotionForms"/> <env name="MAIL_FROM_NAME" value="NotionForms"/>
<server name="QUEUE_CONNECTION" value="sync"/> <env name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<server name="TEMPLATE_EDITOR_EMAILS" value="admin@opnform.com"/> <env name="TEMPLATE_EDITOR_EMAILS" value="admin@opnform.com"/>
<server name="JWT_SECRET" value="9K6whOetAFaokQgSIdbMQZuJuDV5uS2Y"/> <env name="JWT_SECRET" value="9K6whOetAFaokQgSIdbMQZuJuDV5uS2Y"/>
</php> </php>
</phpunit> </phpunit>

View File

@ -20,7 +20,7 @@ it('can hide branding on upgrade', function () {
// User subscribes // User subscribes
$user->subscriptions()->create([ $user->subscriptions()->create([
'name' => 'default', 'type' => 'default',
'stripe_id' => Str::random(), 'stripe_id' => Str::random(),
'stripe_status' => 'active', 'stripe_status' => 'active',
'stripe_price' => Str::random(), 'stripe_price' => Str::random(),

View File

@ -2,8 +2,6 @@
use App\Models\User; use App\Models\User;
use function Pest\Faker\faker;
it('can register', function () { it('can register', function () {
$this->postJson('/register', [ $this->postJson('/register', [
'name' => 'Test User', 'name' => 'Test User',
@ -36,12 +34,12 @@ it('cannot register with existing email', function () {
it('cannot register with disposable email', function () { it('cannot register with disposable email', function () {
// Select random email // Select random email
$email = faker()->randomElement([ $email = [
'dumliyupse@gufum.com', 'dumliyupse@gufum.com',
'kcs79722@zslsz.com', 'kcs79722@zslsz.com',
'pfizexwxtdifxupdhr@tpwlb.com', 'pfizexwxtdifxupdhr@tpwlb.com',
'qvj86ypqfm@email.edu.pl', 'qvj86ypqfm@email.edu.pl',
]); ][rand(0, 3)];
$this->postJson('/register', [ $this->postJson('/register', [
'name' => 'Test disposable', 'name' => 'Test disposable',

View File

@ -169,7 +169,7 @@ trait TestHelpers
$user = $this->createUser(); $user = $this->createUser();
$user->subscriptions()->create([ $user->subscriptions()->create([
'name' => 'default', 'type' => 'default',
'stripe_id' => Str::random(), 'stripe_id' => Str::random(),
'stripe_status' => 'active', 'stripe_status' => 'active',
'stripe_price' => Str::random(), 'stripe_price' => Str::random(),