From 62afdf3f2c6ba9b1a4b40519e351718010b4060e Mon Sep 17 00:00:00 2001 From: Colin Viebrock Date: Wed, 23 May 2012 22:47:18 -0500 Subject: [PATCH 1/2] Allow password field to be configured. Signed-off-by: Colin Viebrock --- application/config/auth.php | 13 +++++++++++++ laravel/auth/drivers/eloquent.php | 6 ++++-- laravel/auth/drivers/fluent.php | 8 +++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/application/config/auth.php b/application/config/auth.php index 0c07c47d..bb500c8b 100644 --- a/application/config/auth.php +++ b/application/config/auth.php @@ -31,6 +31,19 @@ 'username' => 'email', + /* + |-------------------------------------------------------------------------- + | Authentication Password + |-------------------------------------------------------------------------- + | + | Here you may specify the database column that should be considered the + | "password" for your users. Typically, this will be "password" but, again + | you're free to change the value to anything. + | + */ + + 'password' => 'password', + /* |-------------------------------------------------------------------------- | Authentication Model diff --git a/laravel/auth/drivers/eloquent.php b/laravel/auth/drivers/eloquent.php index 5c0437d6..1b588db3 100644 --- a/laravel/auth/drivers/eloquent.php +++ b/laravel/auth/drivers/eloquent.php @@ -15,7 +15,7 @@ public function retrieve($id) if (filter_var($id, FILTER_VALIDATE_INT) !== false) { return $this->model()->find($id); - } + } } /** @@ -35,7 +35,9 @@ public function attempt($arguments = array()) // log the user into the application and remember them if asked. $password = $arguments['password']; - if ( ! is_null($user) and Hash::check($password, $user->password)) + $password_field = Config::get('auth.password'); + + if ( ! is_null($user) and Hash::check($password, $user->get_attribute($password_field))) { return $this->login($user->id, array_get($arguments, 'remember')); } diff --git a/laravel/auth/drivers/fluent.php b/laravel/auth/drivers/fluent.php index 38aa458a..026a437d 100644 --- a/laravel/auth/drivers/fluent.php +++ b/laravel/auth/drivers/fluent.php @@ -19,7 +19,7 @@ public function retrieve($id) if (filter_var($id, FILTER_VALIDATE_INT) !== false) { return DB::table(Config::get('auth.table'))->find($id); - } + } } /** @@ -33,11 +33,13 @@ public function attempt($arguments = array()) $user = $this->get_user($arguments['username']); // This driver uses a basic username and password authentication scheme - // so if the credentials mmatch what is in the database we will just + // so if the credentials match what is in the database we will just // log the user into the application and remember them if asked. $password = $arguments['password']; - if ( ! is_null($user) and Hash::check($password, $user->password)) + $password_field = Config::get('auth.password'); + + if ( ! is_null($user) and Hash::check($password, $user->get_attribute($password_field))) { return $this->login($user->id, array_get($arguments, 'remember')); } From bb2afdf559842c05b678e079bd92b28a8ad3dd58 Mon Sep 17 00:00:00 2001 From: Colin Viebrock Date: Wed, 30 May 2012 11:40:21 -0500 Subject: [PATCH 2/2] Fix for Fluent ... this should work, I'd think --- laravel/auth/drivers/fluent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/auth/drivers/fluent.php b/laravel/auth/drivers/fluent.php index 026a437d..f9d309db 100644 --- a/laravel/auth/drivers/fluent.php +++ b/laravel/auth/drivers/fluent.php @@ -39,7 +39,7 @@ public function attempt($arguments = array()) $password_field = Config::get('auth.password'); - if ( ! is_null($user) and Hash::check($password, $user->get_attribute($password_field))) + if ( ! is_null($user) and Hash::check($password, $user->{$password_field})) { return $this->login($user->id, array_get($arguments, 'remember')); } @@ -62,4 +62,4 @@ protected function get_user($value) return DB::table($table)->where($username, '=', $value)->first(); } -} \ No newline at end of file +}