diff --git a/src/Tappleby/AuthToken/AuthTokenController.php b/src/Tappleby/AuthToken/AuthTokenController.php index bc5db48..ac9f4f0 100644 --- a/src/Tappleby/AuthToken/AuthTokenController.php +++ b/src/Tappleby/AuthToken/AuthTokenController.php @@ -14,6 +14,7 @@ use Request; use Input; use Validator; +use Config; class AuthTokenController extends Controller { @@ -67,15 +68,18 @@ public function store() { $input = Input::all(); $validator = Validator::make( - $input, - array('username' => array('required'), 'password' => array('required')) - ); + $input, + array( + Config::get('laravel-auth-token::login_credential') => Config::get('laravel-auth-token::login_credential_rules'), + Config::get('laravel-auth-token::password_credential') => Config::get('laravel-auth-token::password_credential_rules'), + ) + ); if($validator->fails()) { throw new NotAuthorizedException(); } - $creds = call_user_func($this->credentialsFormatter, $input['username'], $input['password']); + $creds = call_user_func($this->credentialsFormatter, $input[Config::get('laravel-auth-token::login_credential')], $input[Config::get('laravel-auth-token::password_credential')]); $token = $this->driver->attempt($creds); if(!$token) { diff --git a/src/config/config.php b/src/config/config.php index a7a4f93..4dfecb7 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,5 +12,14 @@ 'email' => $username, 'password' => $password ); - } + }, + /** + * Transforms login and password into fields that are received via POST + * + * Rules are also specified + */ + 'login_credential' => 'username', + 'login_credential_rules' => array('required'), + 'password_credential' => 'password', + 'password_credential_rules' => array('required'), ); \ No newline at end of file