From 4e493b78add9da61d4ba345a58a1db77069abca9 Mon Sep 17 00:00:00 2001 From: Simon Erkelens Date: Sun, 13 Aug 2017 16:10:22 +1200 Subject: [PATCH] PSR-2 run. --- src/Authentication/JWTAuthenticator.php | 2 +- src/Types/MemberTokenTypeCreator.php | 1 + tests/unit/CreateTokenMutationCreatorTest.php | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Authentication/JWTAuthenticator.php b/src/Authentication/JWTAuthenticator.php index a1324bd..ce167e4 100644 --- a/src/Authentication/JWTAuthenticator.php +++ b/src/Authentication/JWTAuthenticator.php @@ -213,7 +213,7 @@ private function getValidator($request, $parsedToken) } elseif ($parsedToken->getClaim('uid') > 0) { $member = Member::get()->byID($parsedToken->getClaim('uid')); $id = $member->JWTUniqueID; - } + } $validator->setId($id); diff --git a/src/Types/MemberTokenTypeCreator.php b/src/Types/MemberTokenTypeCreator.php index 876380b..0aeb17c 100644 --- a/src/Types/MemberTokenTypeCreator.php +++ b/src/Types/MemberTokenTypeCreator.php @@ -18,6 +18,7 @@ public function fields() { $string = Type::string(); $id = Type::id(); + return [ 'ID' => ['type' => $id], 'FirstName' => ['type' => $string], diff --git a/tests/unit/CreateTokenMutationCreatorTest.php b/tests/unit/CreateTokenMutationCreatorTest.php index 0cf61a2..ebcfea2 100644 --- a/tests/unit/CreateTokenMutationCreatorTest.php +++ b/tests/unit/CreateTokenMutationCreatorTest.php @@ -33,7 +33,8 @@ public function testResolveValid() { $createToken = Injector::inst()->get(CreateTokenMutationCreator::class); - $response = $createToken->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'error'], [], new ResolveInfo([])); + $response = $createToken->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'error'], [], + new ResolveInfo([])); $this->assertTrue($response instanceof Member); $this->assertNotNull($response->Token); @@ -44,7 +45,8 @@ public function testResolveInvalidWithAllowedAnonymous() Config::modify()->set(JWTAuthenticator::class, 'anonymous_allowed', true); $authenticator = Injector::inst()->get(CreateTokenMutationCreator::class); - $response = $authenticator->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'wrong'], [], new ResolveInfo([])); + $response = $authenticator->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'wrong'], [], + new ResolveInfo([])); $this->assertTrue($response instanceof Member); $this->assertEquals(0, $response->ID); @@ -56,7 +58,8 @@ public function testResolveInvalidWithoutAllowedAnonymous() Config::modify()->set(JWTAuthenticator::class, 'anonymous_allowed', false); $authenticator = Injector::inst()->get(CreateTokenMutationCreator::class); - $response = $authenticator->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'wrong'], [], new ResolveInfo([])); + $response = $authenticator->resolve(null, ['Email' => 'admin@silverstripe.com', 'Password' => 'wrong'], [], + new ResolveInfo([])); $this->assertTrue($response instanceof Member); $this->assertNull($response->Token);