Laravel4 プロジェクトで認証を行おうとしていますが、常に失敗します。
私は PHP 5.3.4 しか使っていないので、https://github.com/robclancy/laravel4-hashingから SHA512 を使用する代替 Hash パッケージをダウンロードしました。
私はすでにユーザーテーブルを持っており (パスワードフィールドには SHA512 ハッシュが事前に入力されており、別のアプリと共有されています)、私のログイン認証方法は次のとおりです。
Route::post('login', function()
{
$userdata = array(
'UserName' => 'SteB',
'password' => '1234'
);
if (Auth::attempt($userdata, true))
{
return Redirect::action('HomeController@Profile');
}
else
{
return Redirect::to('/')->with('login_errors', true);
}
});
http://hash.online-convert.com/sha512-generatorを使用して、SHA512 ハッシュが正しいことも確認しました。
これは常に (黙って) 失敗します。デバッグする理由や方法についてのアイデアをいただければ幸いです。
私のユーザーテーブルは次のとおりです。
UserID int、Identity PK
UserName varchar(24)
FullName varchar(32)
Eメール varchar(64)
パスワード varchar(256)
これは既存の SQL Server 2000 データベースにあります。認証されていないページのユーザー情報を DB から取得しているため、DB ドライバーと接続が正常に機能していることがわかります。
Laravel のユーザー モデル:
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'Users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password');
//protected $fillable = array('UserID', 'UserName', 'FullName');
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier()
{
return $this->getKey();
}
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
/*Now all lowercase to match $userdata as suggested on SO*/
return $this->password;
}
/**
* Get the e-mail address where password reminders are sent.
*
* @return string
*/
public function getReminderEmail()
{
return $this->EMail;
}
}
アップデート:
この記事を見つけました: http://laravel.io/topic/20/hashing-in-laravel。
ランダムソルトを使用したbase64でエンコードされたハッシュは、私が期待したとおりに機能していないようです。