From 9a77c20cc67a62b0517d0e282d8ed07025cfd4f6 Mon Sep 17 00:00:00 2001 From: Franzz Date: Sat, 5 Oct 2019 17:18:28 +0200 Subject: [PATCH] Fix post-sync login --- inc/auth.php | 7 +++---- inc/catc.php | 9 +++++++-- readme.md | 11 ++++++++--- scripts/common.js | 3 +-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/inc/auth.php b/inc/auth.php index 4943958..21e4d87 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -157,7 +157,7 @@ class Auth extends PhpObject return ($this->sApiKey!='' && $sApiKey==$this->sApiKey); } - private function resetPass($iUserId=0) + public function resetPass($iUserId=0) { $sUserIdCol = Db::getId(self::USER_TABLE); $sUserTextCol = Db::getText(self::USER_TABLE); @@ -168,7 +168,7 @@ class Auth extends PhpObject $asUsers = $this->oDb->selectRows($asInfo); foreach($asUsers as $asUser) { - $sToken = self::hashPassword(self::getLoginToken($asUser[$sUserTextCol])); + $sToken = self::hashPassword(self::getLoginToken('123456')); $this->oDb->updateRow(self::USER_TABLE, array(Db::getId(self::USER_TABLE)=>$asUser[$sUserIdCol]), array('pass'=>$sToken)); } } @@ -179,8 +179,7 @@ class Auth extends PhpObject $sServerName = array_key_exists('SERVER_NAME', $_SERVER)?$_SERVER['SERVER_NAME']:$_SERVER['PWD']; $sAppPath = $_SERVER['REQUEST_SCHEME'].'://'.str_replace(array('http://', 'https://'), '', $sServerName.dirname($_SERVER['SCRIPT_NAME'])); $_GET['serv_name'] = $sAppPath.(mb_substr($sAppPath, -1)!='/'?'/':''); - //return md5($sPass.$_GET['serv_name']); - return md5($sPass.'http://localhost/catc/'); + return md5($sPass.$_GET['serv_name']); } private function resetAuthCookie($iUserId) diff --git a/inc/catc.php b/inc/catc.php index afe2241..4b977e6 100644 --- a/inc/catc.php +++ b/inc/catc.php @@ -236,8 +236,13 @@ class CATC extends Main $bSuccess = ($sDesc==''); unlink($sBackupPath); - //Check for missing files - $asMissingFiles = (new Doc($this->oDb))->getMissingFiles(); + if($bSuccess) { + //Reset passwords + $this->oAuth->resetPass(); + + //Check for missing files + $asMissingFiles = (new Doc($this->oDb))->getMissingFiles(); + } //Send list of missing files back return self::getJsonResult($bSuccess, $sDesc, array('files'=>$asMissingFiles)); diff --git a/readme.md b/readme.md index 73d4d2a..2bc61c6 100644 --- a/readme.md +++ b/readme.md @@ -1,15 +1,20 @@ # CATC Notes Prise de notes pour les cours du Collège des Arts Thérapeutiques Chinois +#Install +* Activate PHP modules: curl +* Copy settings-sample.php -> settings.php & update values + # Todo * [x] Upload/Download docs: audio, video, word, pdf * [ ] View docs online: audio, video, word, pdf * [x] Take notes on courses -* [ ] Quick view of muscles / nerves schemas +* [x] Quick view of muscles / nerves schemas * [x] Dictionary * [x] Progress bar * [x] Save note on F5/quit -* [ ] Sync local with remote repository +* [x] Sync local with remote repository * [x] Table in Quill JS * [ ] Font Awesome icons in Quill JS Toolbar -* [ ] Todo lists \ No newline at end of file +* [ ] Todo lists +* [ ] Bug sync + login hash \ No newline at end of file diff --git a/scripts/common.js b/scripts/common.js index 7ba1bf1..de567bc 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -282,8 +282,7 @@ function setElem(anchor, path, value) function getLoginToken(sPass) { if(!window.location.origin) window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); - //return md5(sPass+window.location.origin+window.location.pathname); - return md5(sPass+'http://localhost/catc/'); + return md5(sPass+window.location.origin+window.location.pathname); } var defaultDiacriticsRemovalap = [