diff --git a/src/Api.php b/src/Api.php index c4d0098..6fed3e7 100644 --- a/src/Api.php +++ b/src/Api.php @@ -12,6 +12,7 @@ use Log; use Zoomyboy\LaravelNami\Backend\Backend; use Zoomyboy\LaravelNami\Concerns\IsNamiMember; use Zoomyboy\LaravelNami\Cookies\Cookie; +use Zoomyboy\LaravelNami\Exceptions\RightException; use Zoomyboy\LaravelNami\NamiException; class Api { @@ -149,6 +150,10 @@ class Api { Logger::http($url, $response, 'Single Membership '.$membershipId.' from '.$memberId, ['memberId' => $memberId]); + if($response->json()['success'] === false && Str::startsWith($response['message'], 'Sicherheitsverletzung')) { + throw new RightException(''); + } + return $response->json()['data']; } diff --git a/src/Authentication/NamiGuard.php b/src/Authentication/NamiGuard.php index bf8da36..a956b1a 100644 --- a/src/Authentication/NamiGuard.php +++ b/src/Authentication/NamiGuard.php @@ -2,15 +2,15 @@ namespace Zoomyboy\LaravelNami\Authentication; -use Illuminate\Contracts\Auth\Guard; -use Illuminate\Contracts\Auth\Authenticatable; -use Zoomyboy\LaravelNami\Nami; -use Illuminate\Support\Facades\Cache; -use Zoomyboy\LaravelNami\NamiUser; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; -use Illuminate\Auth\SessionGuard; use Illuminate\Auth\GuardHelpers; +use Illuminate\Auth\SessionGuard; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; +use Illuminate\Contracts\Auth\Authenticatable; +use Illuminate\Contracts\Auth\Guard; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; +use Zoomyboy\LaravelNami\Nami; +use Zoomyboy\LaravelNami\NamiUser; class NamiGuard { diff --git a/src/Exceptions/RightException.php b/src/Exceptions/RightException.php new file mode 100644 index 0000000..309d265 --- /dev/null +++ b/src/Exceptions/RightException.php @@ -0,0 +1,10 @@ +membership($membership['id']); + $m = $this->membership($membership['id']); + + if ($m === null) { + continue; + } + + yield $m; } }); } - public function membership($id): Membership { - return Membership::fromNami(Nami::membership($this->id, $id)); + public function membership($id): ?Membership { + try { + return Membership::fromNami(Nami::membership($this->id, $id)); + } catch (RightException $e) { + return null; + } } }