diff --git a/inc/auth.php b/inc/auth.php index d4bd165..d84c857 100755 --- a/inc/auth.php +++ b/inc/auth.php @@ -66,7 +66,7 @@ class Auth extends PhpObject if(array_key_exists('unknown_user', $asUser)) { - $iUserId = $this->addUser($asUser['username'], $sNickName, $asUser['pass'], $bLogMeIn); + $iUserId = $this->addUser($asUser['username'], $sNickName, $asUser['http_pass'], $bLogMeIn); if($iUserId > 0) $bSuccess = true; else $sDesc = 'Error: Could not add user'; } @@ -89,7 +89,7 @@ class Auth extends PhpObject if($asResult['username']!='' && $asResult['http_pass']!='') { - $asUser = $this->oDb->selectRow(MyThoughts::USER_TABLE, array("MD5(".Db::getText(MyThoughts::USER_TABLE).")"=>$asResult['username'])); + $asUser = $this->oDb->selectRow(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$asResult['username'])); if(!empty($asUser)) { $asResult += $asUser; @@ -134,17 +134,17 @@ class Auth extends PhpObject } } - public function addUser($sUserName, $sNickName, $sPass, $bLogMeIn=false) + public function addUser($sUserHash, $sNickName, $sLoginToken, $bLogMeIn=false) { - $sPass = self::hashPassword($sPass); - $bExist = $this->oDb->pingValue(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sUserName)); + $sPass = self::hashPassword($sLoginToken); + $bExist = $this->oDb->pingValue(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sUserHash)); if($bExist) return -1; else { - $iUserId = $this->oDb->insertRow(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sUserName, 'nickname'=>$sNickName, 'pass'=>$sPass)); + $iUserId = $this->oDb->insertRow(MyThoughts::USER_TABLE, array(Db::getText(MyThoughts::USER_TABLE)=>$sUserHash, 'nickname'=>$sNickName, 'pass'=>$sPass)); if($iUserId>0 && $bLogMeIn) { - $this->logMeIn($sUserName.self::TOKEN_SEP.$sPass); + $this->logMeIn($sUserHash.self::TOKEN_SEP.$sPass); } } return $iUserId; @@ -167,12 +167,12 @@ class Auth extends PhpObject $asUsers = $this->oDb->selectRows($asInfo); foreach($asUsers as $asUser) { - $sToken = self::hashPassword($asUser[$sUserTextCol]); + $sToken = self::hashPassword(self::getLoginToken($asUser[$sUserTextCol])); $this->oDb->updateRow(MyThoughts::USER_TABLE, array(Db::getId(MyThoughts::USER_TABLE)=>$asUser[$sUserIdCol]), array('pass'=>$sToken)); } } - private static function getLoginToken($sPass) + public static function getLoginToken($sPass) { //Add Server Name $sServerName = array_key_exists('SERVER_NAME', $_SERVER)?$_SERVER['SERVER_NAME']:$_SERVER['PWD']; @@ -204,7 +204,7 @@ class Auth extends PhpObject private static function hashPassword($sPass) { - return password_hash(self::getLoginToken($sPass), self::ALGO, array('cost'=>self::COST)); + return password_hash($sPass, self::ALGO, array('cost'=>self::COST)); } private static function checkPassword($sPass, $sHash) diff --git a/inc/mythoughts.php b/inc/mythoughts.php index ff6d526..7f88719 100755 --- a/inc/mythoughts.php +++ b/inc/mythoughts.php @@ -71,7 +71,6 @@ class MyThoughts extends Main //Install DB $this->oDb->install(); - $this->oAuth->addUser('franzz', 'Franzz', '123456'); } private function setContext($sProcessPage) diff --git a/masks/logon.html b/masks/logon.html index c8af905..0c20906 100755 --- a/masks/logon.html +++ b/masks/logon.html @@ -3,15 +3,15 @@
- +
- +
- +
@@ -19,7 +19,7 @@
- + @@ -37,6 +37,7 @@ oMyThoughts.pageInit = function(asHash, bFirstPage) { self.elem.$Main.addClass('no_frame'); + $('[data-toggle="tooltip"]').tooltip(); //$(window).keyup(function(e){if(e.which==13) logMeIn();}); $('#signin').click(logMeIn);