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_DISK=s3
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
BROADCAST_CONNECTION=log
CACHE_STORE=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_LIFETIME=120

View File

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

View File

@ -89,14 +89,17 @@ class Form extends Model implements CachableAttributes
'seo_meta',
];
protected $casts = [
'properties' => 'array',
'database_fields_update' => 'array',
'closes_at' => 'datetime',
'tags' => 'array',
'removed_properties' => 'array',
'seo_meta' => 'object'
];
protected function casts(): array
{
return [
'properties' => 'array',
'database_fields_update' => 'array',
'closes_at' => 'datetime',
'tags' => 'array',
'removed_properties' => 'array',
'seo_meta' => 'object'
];
}
protected $appends = [
'share_url',
@ -129,7 +132,7 @@ class Form extends Model implements CachableAttributes
public function getIsProAttribute()
{
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
*/
protected $casts = [
'data' => 'array',
];
protected function casts(): array
{
return [
'data' => 'array',
];
}
/**
* Relationships

View File

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

View File

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

View File

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

View File

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

View File

@ -29,15 +29,18 @@ class Template extends Model
'related_templates',
];
protected $casts = [
'structure' => 'array',
'questions' => 'array',
'industries' => 'array',
'types' => 'array',
'related_templates' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected function casts()
{
return [
'structure' => 'array',
'questions' => 'array',
'industries' => 'array',
'types' => 'array',
'related_templates' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
protected $attributes = [
'publicly_listed' => false,
@ -49,7 +52,7 @@ class Template extends Model
public function getShareUrlAttribute()
{
return front_url('/form-templates/'.$this->slug);
return front_url('/form-templates/' . $this->slug);
}
public function setDescriptionAttribute($value)

View File

@ -45,9 +45,12 @@ class User extends Authenticatable implements JWTSubject
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected function casts()
{
return [
'email_verified_at' => 'datetime',
];
}
/**
* The accessors to append to the model's array form.
@ -90,12 +93,12 @@ class User extends Authenticatable implements JWTSubject
{
return $this->subscribed()
|| in_array($this->email, config('opnform.extra_pro_users_emails'))
|| ! is_null($this->activeLicense());
|| !is_null($this->activeLicense());
}
public function getHasCustomerIdAttribute()
{
return ! is_null($this->stripe_id);
return !is_null($this->stripe_id);
}
public function getAdminAttribute()

View File

@ -32,9 +32,12 @@ class Workspace extends Model implements CachableAttributes
'is_enterprise',
];
protected $casts = [
'custom_domains' => 'array',
];
protected function casts()
{
return [
'custom_domains' => 'array',
];
}
protected $cachableAttributes = [
'is_pro',
@ -149,7 +152,7 @@ class Workspace extends Model implements CachableAttributes
return $this->remember('is_risky', 15 * 60, function (): bool {
// A workspace is risky if all of his users are risky
foreach ($this->owners as $owner) {
if (! $owner->is_risky) {
if (!$owner->is_risky) {
return false;
}
}

View File

@ -36,8 +36,6 @@ class AuthServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->registerPolicies();
\Illuminate\Support\Facades\Gate::define('viewMailcoach', function ($user = null) {
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()
{
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;
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.
@ -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.
*

View File

@ -2,11 +2,12 @@
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Str;
class FormPropertyLogicRule implements DataAwareRule, Rule
class FormPropertyLogicRule implements DataAwareRule, ValidationRule
{
public const ACTIONS_VALUES = [
'show-block',
@ -803,6 +804,13 @@ class FormPropertyLogicRule implements DataAwareRule, Rule
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.
*/

View File

@ -2,10 +2,11 @@
namespace App\Rules;
use Closure;
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;
@ -153,6 +154,13 @@ class IntegrationLogicRule implements DataAwareRule, Rule
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.
*/

View File

@ -2,9 +2,10 @@
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.
@ -38,6 +39,13 @@ class OneEmailPerLine implements Rule
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.
*

View File

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

View File

@ -2,6 +2,7 @@
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ImplicitRule;
use Illuminate\Support\Facades\Http;
@ -31,6 +32,12 @@ class ValidHCaptcha implements ImplicitRule
'response' => $value,
])->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.

View File

@ -2,9 +2,10 @@
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;
@ -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()
{
return match ($this->reason) {

View File

@ -2,9 +2,10 @@
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.
@ -21,6 +22,13 @@ class ValidUrl implements Rule
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.
*

View File

@ -1,117 +1,111 @@
{
"name": "jhumanj/opnform",
"description": "A beautiful open-source form builder ",
"keywords": [
"form",
"api",
"laravel",
"vue",
"nuxt",
"Tailwind"
],
"license": "MIT",
"type": "project",
"require": {
"php": "^8.2",
"ext-json": "*",
"aws/aws-sdk-php": "^3.183",
"doctrine/dbal": "^3.4",
"giggsey/libphonenumber-for-php": "^8.13",
"google/apiclient": "^2.15.0",
"guzzlehttp/guzzle": "^7.0.1",
"jhumanj/laravel-model-stats": "^0.4.0",
"laravel/cashier": "^13.4",
"laravel/framework": "^9.19.0",
"laravel/horizon": "^5.7",
"laravel/socialite": "^5.2",
"laravel/tinker": "^2.6",
"laravel/ui": "^3.2",
"laravel/vapor-cli": "^1.38",
"laravel/vapor-core": "^2.21",
"laravel/vapor-ui": "^1.5",
"league/flysystem-aws-s3-v3": "^3.0",
"maatwebsite/excel": "^3.1",
"openai-php/client": "^0.6.4",
"propaganistas/laravel-disposable-email": "^2.2",
"sentry/sentry-laravel": "^2.11.0",
"spatie/laravel-data": "^3.12",
"spatie/laravel-sitemap": "^6.0",
"spatie/laravel-sluggable": "^3.0",
"stevebauman/purify": "^v6.2.0",
"tymon/jwt-auth": "^1.0.2",
"vinkla/hashids": "^10.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.12",
"fakerphp/faker": "^1.9.1",
"laravel/dusk": "^6.8",
"laravel/pint": "^1.14",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^6.1",
"pestphp/pest": "^1.15",
"pestphp/pest-plugin-faker": "^1.0",
"pestphp/pest-plugin-laravel": "^1.1",
"pestphp/pest-plugin-parallel": "^1.2",
"phpunit/phpunit": "^9.3.3",
"spatie/laravel-ignition": "^1.0",
"spatie/laravel-ray": "^1.17"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"platform": {
"ext-pcntl": "8.0",
"ext-posix": "8.0"
},
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"extra": {
"laravel": {
"dont-discover": [
"laravel/dusk"
]
},
"google/apiclient-services": [
"Sheets"
]
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"pre-autoload-dump": "Google\\Task\\Composer::cleanup",
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
"name": "jhumanj/opnform",
"description": "A beautiful open-source form builder ",
"keywords": [
"form",
"api",
"laravel",
"vue",
"nuxt",
"Tailwind"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php artisan jwt:secret --force --ansi"
],
"post-update-cmd": [
"@php artisan vapor-ui:publish --ansi"
]
}
"license": "MIT",
"type": "project",
"require": {
"php": "^8.2",
"ext-json": "*",
"aws/aws-sdk-php": "*",
"doctrine/dbal": "*",
"giggsey/libphonenumber-for-php": "*",
"google/apiclient": "^2.16",
"guzzlehttp/guzzle": "*",
"laravel/cashier": "*",
"laravel/framework": "^11.9",
"laravel/horizon": "*",
"laravel/socialite": "*",
"laravel/tinker": "^2.9",
"laravel/ui": "*",
"laravel/vapor-cli": "*",
"laravel/vapor-core": "*",
"league/flysystem-aws-s3-v3": "*",
"maatwebsite/excel": "^3.1",
"openai-php/client": "*",
"propaganistas/laravel-disposable-email": "*",
"sentry/sentry-laravel": "*",
"spatie/laravel-data": "^4.6",
"spatie/laravel-sitemap": "*",
"spatie/laravel-sluggable": "*",
"stevebauman/purify": "*",
"tymon/jwt-auth": "*",
"vinkla/hashids": "*"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.0.0",
"fakerphp/faker": "^1.23",
"laravel/dusk": "^8.2.0",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "*",
"pestphp/pest": "^2.0",
"spatie/laravel-ignition": "*",
"spatie/laravel-ray": "*"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"platform": {
"ext-pcntl": "8.0",
"ext-posix": "8.0"
},
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"extra": {
"laravel": {
"dont-discover": [
"laravel/dusk"
]
},
"google/apiclient-services": [
"Sheets"
]
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"pre-autoload-dump": "Google\\Task\\Composer::cleanup",
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php artisan jwt:secret --force --ansi"
],
"post-update-cmd": [
"@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\RouteServiceProvider::class,
App\Providers\VaporUiServiceProvider::class,
App\Providers\ModelStatsServiceProvider::class,
App\Providers\PurifySetupProvider::class,
/*

View File

@ -95,7 +95,7 @@ return [
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'table' => 'password_reset_tokens',
'expire' => 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
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class () extends Migration {
/**
@ -13,7 +15,12 @@ return new class () extends Migration {
public function up()
{
Schema::table('forms', function (Blueprint $table) {
$table->text('max_submissions_reached_text')->nullable()->default('This form has now reached the maximum number of allowed submissions and is now closed.')->change();
$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();
}
});
}

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

View File

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

View File

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

View File

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