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

Leverage updated config() functionality #60

Merged
merged 6 commits into from
Jun 30, 2019
Merged
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
4 changes: 2 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ line and correct me. I'll make sure to read through it and try to correct either

The included class, `Myth\Auth\Authentication\LocalAuthentication`, together with the `LoginModel` is the power
behind the features listed below. If you want to create your own, create a new class that implements the
`Myth\Auth\Authentication\AuthenticateInterface`. Then modify `application/Config/App.php` to use the new class. This
`Myth\Auth\Authentication\AuthenticateInterface`. Then modify `app/Config/App.php` to use the new class. This
will be automatically loaded up and readied for any class that uses the [Auth Trait](auth_trait.md).

## Logging Users In
Expand Down Expand Up @@ -119,7 +119,7 @@ You can have a user be remembered, through the user of cookies, by passing true
`attempt()` method, as described above. But what happens then? I have tried to make the process as secure as possible,
and will describe the process here so that you can understand the flow.

If you do NOT want your users to be able to use persistent logins, you can turn this off in `application/Config/Auth.php`,
If you do NOT want your users to be able to use persistent logins, you can turn this off in `app/Config/Auth.php`,
along with a number of other settings. See the section on [Configuration](#configuration), below.

### Security Flow
Expand Down
11 changes: 2 additions & 9 deletions src/Config/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@ public static function authentication(string $lib = 'local', Model $userModel=nu
return self::getSharedInstance('authentication', $lib, $userModel, $loginModel);
}

// prioritizes user config in app/Config if found
if (class_exists('\Config\Auth'))
{
$config = new \Config\Auth();
}
else
{
$config = config(Auth::class);
}
// config() checks first in app/Config
$config = config('Auth');

$class = $config->authenticationLibs[$lib];

Expand Down
3 changes: 1 addition & 2 deletions src/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use CodeIgniter\Controller;
use Config\Email;
use Myth\Auth\Config\Auth;
use Myth\Auth\Config\Services;
use Myth\Auth\Entities\User;
use Myth\Auth\Models\UserModel;
Expand All @@ -26,7 +25,7 @@ public function __construct()
// the session to be started - so fire it up!
$this->session = Services::session();

$this->config = config(Auth::class);
$this->config = config('Auth');
$this->auth = Services::authentication();
}

Expand Down
3 changes: 1 addition & 2 deletions src/Entities/User.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Myth\Auth\Entities;

use CodeIgniter\Entity;
use Myth\Auth\Config\Auth;

class User extends Entity
{
Expand Down Expand Up @@ -40,7 +39,7 @@ class User extends Entity
*/
public function setPassword(string $password)
{
$config = config(Auth::class);
$config = config('Auth');

$this->attributes['password_hash'] = password_hash(
base64_encode(
Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/AuthException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php namespace Myth\Auth\Exceptions;

use Myth\Auth\Config\Auth;

class AuthException extends \DomainException implements ExceptionInterface
{
public static function forInvalidModel(string $model)
Expand Down
3 changes: 1 addition & 2 deletions src/Models/LoginModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Myth\Auth\Models;

use CodeIgniter\Model;
use Myth\Auth\Config\Auth;
use Myth\Auth\Entities\User;

class LoginModel extends Model
Expand Down Expand Up @@ -99,7 +98,7 @@ public function purgeRememberTokens(int $id)
*/
public function purgeOldRememberTokens()
{
$config = config(Auth::class);
$config = config('Auth');

if (! $config->allowRemembering)
{
Expand Down