Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make credentials configurable #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions config/multiauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,17 @@
'role' => Bitfumes\Multiauth\Model\Role::class,
'permission' => Bitfumes\Multiauth\Model\Permission::class,
],

/*
|--------------------------------------------------------------------------
| Admin Credentials
|--------------------------------------------------------------------------
|
| When attempting a login the following additional credentials are
| provided to the authenticator to check in the admins table.
|
*/
'credentials' => [
'active' => 1,
],
];
24 changes: 24 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ You can set your own model and define here to use by package.
'role' => Bitfumes\Multiauth\Model\Role::class,
'permission' => Bitfumes\Multiauth\Model\Permission::class,
],

...
```

## Credentials

You can set your own credentials to be passed to the authenticator with the username and password.

By default we check that the `active` column of the `admins` table is true.

```php{11,12,13}
...
/*
|--------------------------------------------------------------------------
| Admin Credentials
|--------------------------------------------------------------------------
|
| When attempting a login the following additional credentials are
| provided to the authenticator to check in the admins table.
|
*/
'credentials' => [
'active' => 1,
],
];


Expand Down
11 changes: 9 additions & 2 deletions src/Http/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ public function showLoginForm()
*/
protected function credentials(Request $request)
{
$request['active'] = 1;
$extraCredentials = config('multiauth.credentials', [
'active' => 1,
]);

$request->merge($extraCredentials);

return $request->only($this->username(), 'password', 'active');
return $request->only(array_merge(
[$this->username(), 'password'],
array_keys($extraCredentials),
));
}

/**
Expand Down