Fix post-sync login

This commit is contained in:
2019-10-05 17:18:28 +02:00
parent 4e1738a427
commit 9a77c20cc6
4 changed files with 19 additions and 11 deletions

View File

@@ -157,7 +157,7 @@ class Auth extends PhpObject
return ($this->sApiKey!='' && $sApiKey==$this->sApiKey); return ($this->sApiKey!='' && $sApiKey==$this->sApiKey);
} }
private function resetPass($iUserId=0) public function resetPass($iUserId=0)
{ {
$sUserIdCol = Db::getId(self::USER_TABLE); $sUserIdCol = Db::getId(self::USER_TABLE);
$sUserTextCol = Db::getText(self::USER_TABLE); $sUserTextCol = Db::getText(self::USER_TABLE);
@@ -168,7 +168,7 @@ class Auth extends PhpObject
$asUsers = $this->oDb->selectRows($asInfo); $asUsers = $this->oDb->selectRows($asInfo);
foreach($asUsers as $asUser) 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)); $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']; $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'])); $sAppPath = $_SERVER['REQUEST_SCHEME'].'://'.str_replace(array('http://', 'https://'), '', $sServerName.dirname($_SERVER['SCRIPT_NAME']));
$_GET['serv_name'] = $sAppPath.(mb_substr($sAppPath, -1)!='/'?'/':''); $_GET['serv_name'] = $sAppPath.(mb_substr($sAppPath, -1)!='/'?'/':'');
//return md5($sPass.$_GET['serv_name']); return md5($sPass.$_GET['serv_name']);
return md5($sPass.'http://localhost/catc/');
} }
private function resetAuthCookie($iUserId) private function resetAuthCookie($iUserId)

View File

@@ -236,8 +236,13 @@ class CATC extends Main
$bSuccess = ($sDesc==''); $bSuccess = ($sDesc=='');
unlink($sBackupPath); unlink($sBackupPath);
//Check for missing files if($bSuccess) {
$asMissingFiles = (new Doc($this->oDb))->getMissingFiles(); //Reset passwords
$this->oAuth->resetPass();
//Check for missing files
$asMissingFiles = (new Doc($this->oDb))->getMissingFiles();
}
//Send list of missing files back //Send list of missing files back
return self::getJsonResult($bSuccess, $sDesc, array('files'=>$asMissingFiles)); return self::getJsonResult($bSuccess, $sDesc, array('files'=>$asMissingFiles));

View File

@@ -1,15 +1,20 @@
# CATC Notes # CATC Notes
Prise de notes pour les cours du Collège des Arts Thérapeutiques Chinois 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 # Todo
* [x] Upload/Download docs: audio, video, word, pdf * [x] Upload/Download docs: audio, video, word, pdf
* [ ] View docs online: audio, video, word, pdf * [ ] View docs online: audio, video, word, pdf
* [x] Take notes on courses * [x] Take notes on courses
* [ ] Quick view of muscles / nerves schemas * [x] Quick view of muscles / nerves schemas
* [x] Dictionary * [x] Dictionary
* [x] Progress bar * [x] Progress bar
* [x] Save note on F5/quit * [x] Save note on F5/quit
* [ ] Sync local with remote repository * [x] Sync local with remote repository
* [x] Table in Quill JS * [x] Table in Quill JS
* [ ] Font Awesome icons in Quill JS Toolbar * [ ] Font Awesome icons in Quill JS Toolbar
* [ ] Todo lists * [ ] Todo lists
* [ ] Bug sync + login hash

View File

@@ -282,8 +282,7 @@ function setElem(anchor, path, value)
function getLoginToken(sPass) function getLoginToken(sPass)
{ {
if(!window.location.origin) window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); 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+window.location.origin+window.location.pathname);
return md5(sPass+'http://localhost/catc/');
} }
var defaultDiacriticsRemovalap = [ var defaultDiacriticsRemovalap = [