forked from lonnieezell/myth-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch allows Myth:Auth to support all three of SQLite, MariaDB and PostgreSQL. - change 'tinyint' to 'boolean' on the migration, - switch 0/1 to true/false coherently throughout the code. Fix lonnieezell#324
- Loading branch information
Showing
7 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Myth\Auth\Entities\Cast; | ||
|
||
use CodeIgniter\Entity\Cast\BaseCast; | ||
|
||
/** | ||
* Class BooleanCast | ||
*/ | ||
class BooleanCast extends BaseCast | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public static function get($value, array $params = []): bool | ||
{ | ||
// PostgreSQL (via PDO, etc.) returns (string)'f' or 't' for boolean | ||
// fields | ||
return (bool) $value && $value !== 'f'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ public function testAttemptLoginSuccess() | |
'username' => 'Joe Cool', | ||
'email' => '[email protected]', | ||
'password' => 'xaH96AhjglK', | ||
'active' => 1, | ||
'active' => true, | ||
]; | ||
$this->createUser($user); | ||
|
||
|
@@ -98,7 +98,7 @@ public function testAttemptLoginSuccessWithRememberMe() | |
'username' => 'Joe Cool', | ||
'email' => '[email protected]', | ||
'password' => 'xaH96AhjglK', | ||
'active' => 1, | ||
'active' => true, | ||
]; | ||
$this->createUser($user); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ public function testRecordLoginAttemptSuccess() | |
'email' => '[email protected]', | ||
'user_id' => 12, | ||
'date' => date('Y-m-d H:i:s'), | ||
'success' => 0 | ||
'success' => false, | ||
]))->andReturn(true); | ||
|
||
$this->assertTrue($this->auth->recordLoginAttempt($credentials['email'], '0.0.0.0', 12, false)); | ||
|