fix registering
This commit is contained in:
20
inc/auth.php
20
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)
|
||||
|
||||
Reference in New Issue
Block a user