From 22f023b0403e161cc0aed36b465529f0877e691a Mon Sep 17 00:00:00 2001 From: William Date: Mon, 30 May 2022 17:43:00 +0000 Subject: [PATCH] Commit --- app/lib/App/Core/User.php | 9 ++++++++- app/lib/App/Teamtable/TeamMapper.php | 4 ++-- public/login.php | 6 +++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/lib/App/Core/User.php b/app/lib/App/Core/User.php index cc184e1..80e577c 100644 --- a/app/lib/App/Core/User.php +++ b/app/lib/App/Core/User.php @@ -96,7 +96,14 @@ class User $sth->execute([$username, $password]); if ($sth->rowCount()) { - return TRUE; + $row = $sth->fetch(PDO::FETCH_ASSOC); + if ( + $row['Brukernavn'] === $username && + $row['Passord'] === $password + ) + { + return TRUE; + } } return FALSE; } diff --git a/app/lib/App/Teamtable/TeamMapper.php b/app/lib/App/Teamtable/TeamMapper.php index 5b9cc43..b2283de 100644 --- a/app/lib/App/Teamtable/TeamMapper.php +++ b/app/lib/App/Teamtable/TeamMapper.php @@ -97,8 +97,8 @@ class TeamMapper $team->rounds, $team->best_time ]); - $lastId = $this->dbh->lastInsertId(); - return $this->get($lastId); + $last_id = $this->dbh->lastInsertId(); + return $this->get($last_id); } public function update(Team $team): Team diff --git a/public/login.php b/public/login.php index daaed11..6685ff5 100644 --- a/public/login.php +++ b/public/login.php @@ -5,11 +5,11 @@ if ($app->user->logged_in) $app->redirect('index.php'); } -$username = (string)filter_input(INPUT_POST, 'username'); -$password = (string)filter_input(INPUT_POST, 'password'); - if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $username = (string)filter_input(INPUT_POST, 'username'); + $password = (string)filter_input(INPUT_POST, 'password'); + if ($app->user->login($username, $password)) { $app->session->flash("Velkommen {$username}!");