From 6d5ada252202bfb29eba884cf9567e969d798607 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 9 Jul 2019 22:02:07 +0200 Subject: [PATCH] Added validation to AuthController --- resources/lang/de_DE/default.mo | Bin 46271 -> 46206 bytes resources/lang/de_DE/default.po | 18 +++-- resources/lang/en_US/default.mo | Bin 745 -> 770 bytes resources/lang/en_US/default.po | 16 +++-- src/Controllers/AuthController.php | 62 ++++++++---------- tests/Unit/Controllers/AuthControllerTest.php | 59 ++++++++++------- 6 files changed, 87 insertions(+), 68 deletions(-) diff --git a/resources/lang/de_DE/default.mo b/resources/lang/de_DE/default.mo index 35ad80b7d015389273df697011f24456154496a6..fb93d59098f243fc9f3d8f04dc65da27eb7ce8d5 100644 GIT binary patch delta 12477 zcmY+~33yJ|zQ^%RBr+m12}wjqB9cfDGbvJHDm81-lpshV#!|ehW>UkesHv!#V{UQK zmKs~taysF(=%7l~F;rVU<$ixz%e}q(c~(E`zt-A&jeEao&w1~s(vPl}c6}36=5>dw zO=-uejL!!-POyjLtcX*o<6N)pII;K>MxlS27qGmHroMqLZFweYg`UA|%)v0+ zit6wvYN=1726_S2@prcTHmcvp8LYoL@~_WwU?ggZSD+rS8a1Gus1?|c8ps!@0bEAS z{0?e{{tX1yTh()bHA_ij}YikT8e$GWkuR{@PB^IHU>Mg8@JFKTLg!n2} z!v{#8PDCTeNx&|ciW6+S4ReS;$68pwvEwww0jT@eqF!g$30v?3@@hIhP0WKDqiz_A z&2cm8K|k3zj7rAfbVto}K57C>P)okSmhV6f>>X5x*HA0z*{ozBE+>GDPHP%!DVw0S zqCM(?eNam{47D|5P)j)#wd6}tTe1Q*kTt01Y(j1Ae$?}iV-5Tiwe-K0)U*EqOivv} zpc*EkI;e{pNE_6Hdf{3ei0arU(`;1$h7(sp4ImBmoCc^BYl)h`aMW|gquR|tZx@-@ z$Y{@(pl0%xjW?l|ZZGPA-&=2^9{3Q|zRXjm-Urn|2)4(n7=;C>6)8sbvl6uho6*Iq z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$@)yZ8Aks;B+WH?2XqlIK!t{>w?gg^H_ zyaK52>HRe(%#%#%XG9E9jp|eOu5U;`L%KJ2MiQgRe?@d7JqD{%_doXDn&hVw{5m*0 zDf4n^+Itr_jrV-WE&2xQdV}anjG}BZF~&Zwy2nVr zNB9!Wh~WEM{6^cb2Y{``l)DQABdu$J?RwUXKwfun-a|_FTz>G!^_Vm22(cC zmJhLIzu*zd4qG>qe<$Zhyi4_?xQ|#%`gdXz>E=YIhmT?jF^(utKe~EQ--7fq?_+Tho-lIrC`}^% zMOxR3#B|ctY<@raUiRr;x`As8b$zi5JQU`vd&ZPm2xyiD0M z<~u`&RJtg5n@A+xju=e(1wz+PL_NxMoyHYJAHs)tma+)!N1P=VlfOhP_70AZh?`4E zYr33@E@B*!K1lU(@)Q^x0HD*(L=}OO_`EkdLS<#wBn5S-{JWq^D-+$_9}GEm{u?$ z!m77)Mnvj)In33yBWm0+G^}AC;ClvA~L0~mi!P|T47Ja^4_$)_5KeTa(?yz diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index cd696610..1f0372af 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Engelsystem\n" "POT-Creation-Date: 2019-04-28 15:23+0200\n" -"PO-Revision-Date: 2019-06-12 16:07+0200\n" +"PO-Revision-Date: 2019-06-13 11:54+0200\n" "Last-Translator: msquare \n" "Language-Team: \n" "Language: de_DE\n" @@ -1529,9 +1529,8 @@ msgstr "Nachname" msgid "Entry required!" msgstr "Pflichtfeld!" -#: includes/pages/guest_login.php:414 -msgid "auth.no-password" -msgstr "Gib bitte ein Passwort ein." +#~ msgid "auth.no-password" +#~ msgstr "Gib bitte ein Passwort ein." #: includes/pages/guest_login.php:418 msgid "auth.not-found" @@ -1539,9 +1538,8 @@ msgstr "" "Es wurde kein Engel gefunden. Probiere es bitte noch einmal. Wenn das Problem " "weiterhin besteht, melde dich im Himmel." -#: includes/pages/guest_login.php:451 includes/view/User_view.php:130 -msgid "auth.no-nickname" -msgstr "Gib bitte einen Nick an." +#~ msgid "auth.no-nickname" +#~ msgstr "Gib bitte einen Nick an." #: includes/pages/guest_login.php:481 #: includes/view/User_view.php:122 @@ -2765,3 +2763,9 @@ msgid "" msgstr "" "Diese Seite existiert nicht oder Du hast keinen Zugriff. Melde Dich an um " "Zugriff zu erhalten!" + +msgid "validation.password.required" +msgstr "Bitte gib ein Passwort an." + +msgid "validation.login.required" +msgstr "Bitte gib einen Loginnamen an." diff --git a/resources/lang/en_US/default.mo b/resources/lang/en_US/default.mo index e95ae7038db0dddb2327828cd145df1902bccfaf..7ef9c3b2c086aec2c1c210507ed820614e9f409d 100644 GIT binary patch delta 237 zcmaFK+Qc?NrJj$0fuRtHC4smBh-H9y77!m~WMJ41q=SICl8J#q8c3f3(jav&fHY8= zffjfJ>38R delta 213 zcmZo-d&xRMrCxx6fuRtHL39%k^8xW>AU?>*z_18NO8{{S6NIh>(m_D}G$0L>W&lzQ z%s>nREFdDWv?N0>FJCt=GdVjiF*g-1P>@($T%KQ)0uw0FP0KIMOJN9@xFb=(Lf6nx y*T`JKz`)ALLfgP_vnFEzqhUZ!YGQG!LTX+~YLP;s0?bG~1~dtn(R!0Bm_h*KoHH;0 diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index 22566e52..54847e61 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Engelsystem 2.0\n" "POT-Creation-Date: 2017-12-29 19:01+0100\n" -"PO-Revision-Date: 2018-11-27 00:28+0100\n" +"PO-Revision-Date: 2019-06-04 23:41+0200\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,11 +16,17 @@ msgstr "" "Language: en_US\n" "X-Poedit-SearchPath-0: .\n" -msgid "auth.no-nickname" -msgstr "Please enter a nickname." +#~ msgid "auth.no-nickname" +#~ msgstr "Please enter a nickname." -msgid "auth.no-password" -msgstr "Please enter a password." +#~ msgid "auth.no-password" +#~ msgstr "Please enter a password." msgid "auth.not-found" msgstr "No user was found. Please try again. If you are still having problems, ask Heaven." + +msgid "validation.password.required" +msgstr "The password is required." + +msgid "validation.login.required" +msgstr "The login name is required." diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index e5fc40e3..a8cc1ace 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -8,6 +8,8 @@ use Engelsystem\Http\Request; use Engelsystem\Http\Response; use Engelsystem\Http\UrlGeneratorInterface; use Engelsystem\Models\User\User; +use Illuminate\Support\Arr; +use Illuminate\Support\Collection; use Symfony\Component\HttpFoundation\Session\SessionInterface; class AuthController extends BaseController @@ -53,7 +55,22 @@ class AuthController extends BaseController */ public function login() { - return $this->response->withView('pages/login'); + return $this->showLogin(); + } + + /** + * @param bool $showRecovery + * @return Response + */ + protected function showLogin($showRecovery = false) + { + $errors = Collection::make(Arr::flatten($this->session->get('errors', []))); + $this->session->remove('errors'); + + return $this->response->withView( + 'pages/login', + ['errors' => $errors, 'show_password_recovery' => $showRecovery] + ); } /** @@ -64,15 +81,18 @@ class AuthController extends BaseController */ public function postLogin(Request $request): Response { - $return = $this->authenticateUser($request->get('login', ''), $request->get('password', '')); - if (!$return instanceof User) { - return $this->response->withView( - 'pages/login', - ['errors' => [$return], 'show_password_recovery' => true] - ); - } + $data = $this->validate($request, [ + 'login' => 'required', + 'password' => 'required', + ]); - $user = $return; + $user = $this->auth->authenticate($data['login'], $data['password']); + + if (!$user instanceof User) { + $this->session->set('errors', $this->session->get('errors', []) + ['auth.not-found']); + + return $this->showLogin(true); + } $this->session->invalidate(); $this->session->set('user_id', $user->id); @@ -93,28 +113,4 @@ class AuthController extends BaseController return $this->response->redirectTo($this->url->to('/')); } - - /** - * Verify the user and password - * - * @param $login - * @param $password - * @return User|string - */ - protected function authenticateUser(string $login, string $password) - { - if (!$login) { - return 'auth.no-nickname'; - } - - if (!$password) { - return 'auth.no-password'; - } - - if (!$user = $this->auth->authenticate($login, $password)) { - return 'auth.not-found'; - } - - return $user; - } } diff --git a/tests/Unit/Controllers/AuthControllerTest.php b/tests/Unit/Controllers/AuthControllerTest.php index 0fad3b6d..d3dbfa4b 100644 --- a/tests/Unit/Controllers/AuthControllerTest.php +++ b/tests/Unit/Controllers/AuthControllerTest.php @@ -4,15 +4,21 @@ namespace Engelsystem\Test\Unit\Controllers; use Engelsystem\Controllers\AuthController; use Engelsystem\Helpers\Authenticator; +use Engelsystem\Http\Exceptions\ValidationException; use Engelsystem\Http\Request; use Engelsystem\Http\Response; use Engelsystem\Http\UrlGeneratorInterface; +use Engelsystem\Http\Validation\Validates; +use Engelsystem\Http\Validation\Validator; use Engelsystem\Models\User\Settings; use Engelsystem\Models\User\User; use Engelsystem\Test\Unit\HasDatabase; +use Illuminate\Support\Collection; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; class AuthControllerTest extends TestCase { @@ -21,6 +27,7 @@ class AuthControllerTest extends TestCase /** * @covers \Engelsystem\Controllers\AuthController::__construct * @covers \Engelsystem\Controllers\AuthController::login + * @covers \Engelsystem\Controllers\AuthController::showLogin */ public function testLogin() { @@ -31,6 +38,10 @@ class AuthControllerTest extends TestCase /** @var Authenticator|MockObject $auth */ list(, $session, $url, $auth) = $this->getMocks(); + $session->expects($this->once()) + ->method('get') + ->with('errors', []) + ->willReturn(['foo' => 'bar']); $response->expects($this->once()) ->method('withView') ->with('pages/login') @@ -42,7 +53,6 @@ class AuthControllerTest extends TestCase /** * @covers \Engelsystem\Controllers\AuthController::postLogin - * @covers \Engelsystem\Controllers\AuthController::authenticateUser */ public function testPostLogin() { @@ -51,10 +61,12 @@ class AuthControllerTest extends TestCase $request = new Request(); /** @var Response|MockObject $response */ $response = $this->createMock(Response::class); - /** @var SessionInterface|MockObject $session */ /** @var UrlGeneratorInterface|MockObject $url */ /** @var Authenticator|MockObject $auth */ - list(, $session, $url, $auth) = $this->getMocks(); + list(, , $url, $auth) = $this->getMocks(); + $session = new Session(new MockArraySessionStorage()); + /** @var Validator|MockObject $validator */ + $validator = new Validator(new Validates()); $user = new User([ 'name' => 'foo', @@ -63,7 +75,7 @@ class AuthControllerTest extends TestCase 'api_key' => '', 'last_login_at' => null, ]); - $user->forceFill(['id' => 42,]); + $user->forceFill(['id' => 42]); $user->save(); $settings = new Settings(['language' => 'de_DE', 'theme' => '']); @@ -76,41 +88,42 @@ class AuthControllerTest extends TestCase ->with('foo', 'bar') ->willReturnOnConsecutiveCalls(null, $user); - $response->expects($this->exactly(3)) + $response->expects($this->once()) ->method('withView') - ->withConsecutive( - ['pages/login', ['errors' => ['auth.no-nickname'], 'show_password_recovery' => true]], - ['pages/login', ['errors' => ['auth.no-password'], 'show_password_recovery' => true]], - ['pages/login', ['errors' => ['auth.not-found'], 'show_password_recovery' => true]]) + ->with('pages/login', ['errors' => Collection::make(['auth.not-found']), 'show_password_recovery' => true]) ->willReturn($response); $response->expects($this->once()) ->method('redirectTo') ->with('news') ->willReturn($response); - $session->expects($this->once()) - ->method('invalidate'); - - $session->expects($this->exactly(2)) - ->method('set') - ->withConsecutive( - ['user_id', 42], - ['locale', 'de_DE'] - ); - + // No credentials $controller = new AuthController($response, $session, $url, $auth); - $controller->postLogin($request); + $controller->setValidator($validator); + try { + $controller->postLogin($request); + $this->fail('Login without credentials possible'); + } catch (ValidationException $e) { + } - $request = new Request(['login' => 'foo']); - $controller->postLogin($request); + // Missing password + $request = new Request([], ['login' => 'foo']); + try { + $controller->postLogin($request); + $this->fail('Login without password possible'); + } catch (ValidationException $e) { + } - $request = new Request(['login' => 'foo', 'password' => 'bar']); // No user found + $request = new Request([], ['login' => 'foo', 'password' => 'bar']); $controller->postLogin($request); + $this->assertEquals([], $session->all()); + // Authenticated user $controller->postLogin($request); $this->assertNotNull($user->last_login_at); + $this->assertEquals(['user_id' => 42, 'locale' => 'de_DE'], $session->all()); } /**