Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AttemptAuthenticate middleware #1197

Merged
merged 33 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
258f516
Add middleware that attempts authentication
spawnia Feb 13, 2020
154c26e
Apply fixes from StyleCI
spawnia Feb 13, 2020
aa523ad
Merge branch 'master' into attempt-authenticate-middleware
spawnia Feb 19, 2020
fd69ad4
Add up target to Makefile
spawnia Feb 19, 2020
74bb34d
Properly test pagination error messages (#1198)
spawnia Feb 19, 2020
a651090
Test `@paginate` with `scopes` (#1199)
spawnia Feb 19, 2020
9638293
Add support to extend `input`, `interface` and `enum` types (#1203)
faiverson Feb 24, 2020
9a30dc2
Add `@hash` directive and deprecate `@bcrypt` (#1200)
Chrissi2812 Feb 24, 2020
58f6ca0
Add option `passOrdered` to `@method` to pass just the argument… (#1208)
JasonTheAdams Feb 26, 2020
752708e
Fix typo in nested mutation docs (#1210)
crojasaragonez Feb 26, 2020
481f33f
Fix typo in older nested mutation docs, too
spawnia Feb 26, 2020
6a0f817
Correct link to FieldMiddleware interface in docs (#1212)
andershagbard Feb 27, 2020
3b8bd65
Correct link to FieldMiddleware interface in all versions
spawnia Feb 27, 2020
468b697
Replace duplicate `CreateAuthorInput` in docs with `UpdateAutho… (#1215)
Aldo-f Mar 2, 2020
a975e7b
Replace more duplicate `CreateAuthorInput` in docs with `UpdateAuthor…
spawnia Mar 2, 2020
ac52204
Access nested inputs with dot notation in `find` option of `@can` #1216
andershagbard Mar 4, 2020
9996edd
Simplify CanDirectiveDBTest.php (#1220)
spawnia Mar 4, 2020
ce4340a
Restore feature parity in Lumen test helper (#1222)
spawnia Mar 4, 2020
14ef616
Add Utils::classUsesTrait (#1221)
spawnia Mar 4, 2020
6227dbd
Support Laravel 7 (#1219)
spawnia Mar 5, 2020
a827d3e
Apply fixes from StyleCI
spawnia Mar 5, 2020
9cad213
Prepare 4.10 release
spawnia Mar 5, 2020
6c41ac1
Fix Lumen version check (#1224)
spawnia Mar 6, 2020
78d9720
Test status 200 on error (#1228)
spawnia Mar 9, 2020
cc1d0e2
Reenable CI for bensampo/laravel-enum (#1227)
spawnia Mar 9, 2020
5677d3e
Throw GraphQL error when ModelNotFoundException is thrown in Ca… (#1225)
andershagbard Mar 9, 2020
4ed632b
Ensure subscription routes are named uniquely (#1231)
spawnia Mar 12, 2020
6391ef4
Upgrade temporary dev deps to stable versions (#1232)
spawnia Mar 12, 2020
ce11864
Write up tests and docs
spawnia Mar 15, 2020
72073f5
Apply fixes from StyleCI
spawnia Mar 15, 2020
bf1ad36
Merge branch 'master' into attempt-authenticate-middleware
spawnia Mar 15, 2020
f71f260
Fix link to Laravel auth docs
spawnia Mar 15, 2020
7d0ccba
Fix namespace
spawnia Mar 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Utils::classUsesTrait (#1221)
  • Loading branch information
spawnia committed Mar 15, 2020
commit 14ef616cb1116f8a621bdfbffcd8be69899e7adc
8 changes: 2 additions & 6 deletions src/SoftDeletes/SoftDeletesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Nuwave\Lighthouse\Events\RegisterDirectiveNamespaces;
use Nuwave\Lighthouse\Exceptions\DefinitionException;
use Nuwave\Lighthouse\Schema\AST\PartialParser;
use Nuwave\Lighthouse\Support\Utils;

class SoftDeletesServiceProvider extends ServiceProvider
{
Expand All @@ -24,12 +25,7 @@ class SoftDeletesServiceProvider extends ServiceProvider
*/
public static function assertModelUsesSoftDeletes(string $modelClass, string $exceptionMessage): void
{
if (
! in_array(
SoftDeletes::class,
class_uses_recursive($modelClass)
)
) {
if (! Utils::classUsesTrait($modelClass, SoftDeletes::class)) {
throw new DefinitionException($exceptionMessage);
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/SoftDeletes/TrashedDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace Nuwave\Lighthouse\SoftDeletes;

use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Scout\Builder as ScoutBuilder;
use Nuwave\Lighthouse\Exceptions\DefinitionException;
use Nuwave\Lighthouse\Schema\Directives\BaseDirective;
use Nuwave\Lighthouse\Support\Contracts\ArgBuilderDirective;
use Nuwave\Lighthouse\Support\Contracts\DefinedDirective;
Expand Down Expand Up @@ -42,11 +40,10 @@ public function handleBuilder($builder, $value)
$model = $builder->getModel();
}

if (! in_array(SoftDeletes::class, class_uses_recursive($model))) {
throw new DefinitionException(
self::MODEL_MUST_USE_SOFT_DELETES
);
}
SoftDeletesServiceProvider::assertModelUsesSoftDeletes(
get_class($model),
self::MODEL_MUST_USE_SOFT_DELETES
);

if (! isset($value)) {
return $builder;
Expand Down
15 changes: 15 additions & 0 deletions src/Support/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,19 @@ public static function applyEach(\Closure $callback, $valueOrValues)

return array_map($callback, $valueOrValues);
}

/**
* Determine if a class uses a trait.
*
* @param object|string $class
* @param string $trait
* @return bool
*/
public static function classUsesTrait($class, string $trait): bool
{
return in_array(
$trait,
class_uses_recursive($class)
);
}
}