diff --git a/README.md b/README.md index ea60dbb..82c91f7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ I wrote this small application to help my wife learn german but then thought of - php-sqlite3 extension ## Installation -1. Set a password for your new user in username.sql. Find following line and replace 'password' by your preferred password. +1. Set a password for your new user in username.sql. Find following line and replace '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8' by the sha256 hash of your preferred password. ``` INSERT INTO config VALUES(1,'PASSWORD','password'); ``` diff --git a/index.php b/index.php index 999c535..229d660 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ class Auth { } $pass = $this->db->getConfigValueByKey('PASSWORD'); - if($_SERVER['PHP_AUTH_PW'] !== $pass) { + if(hash('sha256', $_SERVER['PHP_AUTH_PW']) !== $pass) { $this->respondWithAccessDenied(); } } @@ -435,7 +435,8 @@ class App { unset($_GET[$key]); } } - +//$db = new DB('username.db'); +//new App($db); $auth = new Auth(); new App($auth->getDBHandle()); ?> diff --git a/username.sql b/username.sql index b35cd25..91e65b6 100644 --- a/username.sql +++ b/username.sql @@ -6,7 +6,7 @@ CREATE TABLE config ( value TEXT NOT NULL ); INSERT INTO config VALUES(0,'NEW_CARD_BOX_ID','4'); -INSERT INTO config VALUES(1,'PASSWORD','password'); +INSERT INTO config VALUES(1,'PASSWORD','5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'); CREATE TABLE boxes ( id INTEGER PRIMARY KEY, name TEXT NOT NULL,