Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Tappleby/AuthToken/AuthTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Request;
use Input;
use Validator;
use Config;

class AuthTokenController extends Controller {

Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 10 additions & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);