Skip to content

Commit

Permalink
Fixed AUTH bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hayakawa committed Nov 17, 2014
1 parent 5e972d4 commit c79fe63
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 7 deletions.
12 changes: 12 additions & 0 deletions risoluto/lib/vendor/Risoluto/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,24 @@ public static function callProviderMethod($operation, array $option = array())
}
break;

// グループNo表示
case 'showGroupByNo':
// パラメタのチェック
if (isset($option['no'])) {
/** @noinspection PhpUndefinedMethodInspection */
$retval = $provider->doOperation($operation, $option);
} else {
$retval = false;
}
break;

// ユーザ/グループ情報全件表示
case 'showUserAll': // FALL THRU
case 'showGroupAll':
/** @noinspection PhpUndefinedMethodInspection */
$retval = $provider->doOperation($operation, array());
break;

// 未定義の場合はfalseを返す
default:
$retval = false;
Expand Down
63 changes: 56 additions & 7 deletions risoluto/lib/vendor/Risoluto/AuthDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private function getSqlDelGroup($tablename)
}

/**
* getSqlShowAllUser()
* getSqlShowUserAll()
*
* ユーザ情報表示のためのSQLを生成する
*
Expand All @@ -281,7 +281,7 @@ private function getSqlDelGroup($tablename)
*
* @return SQL
*/
private function getSqlShowAllUser($tablename)
private function getSqlShowUserAll($tablename)
{
$sql = <<<END_OF_SQL
SELECT
Expand All @@ -302,7 +302,7 @@ private function getSqlShowAllUser($tablename)
}

/**
* getSqlShowAllGroup()
* getSqlShowGroupAll()
*
* グループ情報表示のためのSQLを生成する
*
Expand All @@ -312,7 +312,7 @@ private function getSqlShowAllUser($tablename)
*
* @return SQL
*/
private function getSqlShowAllGroup($tablename)
private function getSqlShowGroupAll($tablename)
{
$sql = <<<END_OF_SQL
SELECT
Expand Down Expand Up @@ -392,6 +392,36 @@ private function getSqlShowGroup($tablename)
return $sql;
}

/**
* getSqlShowGroupByNo()
*
* グループ情報表示のためのSQLを生成する
*
* @access private
*
* @param string $tablename グループ情報テーブル名
*
* @return SQL
*/
private function getSqlShowGroupByNo($tablename)
{
$sql = <<<END_OF_SQL
SELECT
`created_at`
, `created_by`
, `modified_at`
, `modified_by`
, `no`
, `groupid`
, `groupname`
, `status`
FROM $tablename
WHERE `no` = :no
END_OF_SQL;

return $sql;
}

/**
* getParams()
*
Expand Down Expand Up @@ -440,6 +470,13 @@ private function getParams($type, $option)
);
break;

// Noのみ
case 'No':
$retval = array(
array('id' => ':no', 'value' => $option['no'], 'type' => \PDO::PARAM_INT),
);
break;

// デフォルトの場合は空配列を返す
default:
$retval = array();
Expand Down Expand Up @@ -534,8 +571,15 @@ public function doAuth($user, $pass, array $option = array())
// ユーザ情報を取得
$get_user = $this->doOperation('showUser', array('userid' => $user));

// 複数権取得できた場合はエラー
if (count($get_user) > 1) {
return false;
} else {
$auth_user = $get_user[0];
}

// DBから取得したユーザ情報のパスワードと引数で与えられたパスワードを比較する
if (password_verify($pass, $get_user[0]['password'])) {
if (password_verify($pass, $auth_user['password']) and $auth_user['status'] == 1) {
return true;
} else {
return false;
Expand Down Expand Up @@ -598,11 +642,15 @@ public function doOperation($operation, array $option = array())
break;

case 'showUserAll':
$get_data = $instance->doQuery($this->getSqlShowAllUser($info['usertable']));
$get_data = $instance->doQuery($this->getSqlShowUserAll($info['usertable']));
break;

case 'showGroupAll':
$get_data = $instance->doQuery($this->getSqlShowAllGroup($info['grouptable']));
$get_data = $instance->doQuery($this->getSqlShowGroupAll($info['grouptable']));
break;

case 'showGroupByNo':
$get_data = $instance->doQuery($this->getSqlShowGroupByNo($info['grouptable']), $this->getParams('No', $option));
break;

// 未定義の識別子の場合は無条件でfalseを返す
Expand All @@ -620,6 +668,7 @@ public function doOperation($operation, array $option = array())
case 'showGroup':
case 'showUserAll':
case 'showGroupAll':
case 'showGroupByNo':
$retval = $get_data;
break;

Expand Down

0 comments on commit c79fe63

Please sign in to comment.