Commit ca8c74ce authored by Jens Segers's avatar Jens Segers

Fix and re-enable tests for auth

parent 315b84e2
<?php namespace Jenssegers\Mongodb\Auth; <?php namespace Jenssegers\Mongodb\Auth;
use DateTime; use Carbon\Carbon;
use MongoDate; use MongoDB\BSON\UTCDateTime;
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository { class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository {
...@@ -14,7 +14,7 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe ...@@ -14,7 +14,7 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe
*/ */
protected function getPayload($email, $token) protected function getPayload($email, $token)
{ {
return ['email' => $email, 'token' => $token, 'created_at' => new MongoDate]; return ['email' => $email, 'token' => $token, 'created_at' => new UTCDateTime(round(microtime(true) * 1000))];
} }
/** /**
...@@ -25,12 +25,10 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe ...@@ -25,12 +25,10 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe
*/ */
protected function tokenExpired($token) protected function tokenExpired($token)
{ {
// Convert MongoDate to a date string. // Convert UTCDateTime to a date string.
if ($token['created_at'] instanceof MongoDate) if ($token['created_at'] instanceof UTCDateTime)
{ {
$date = new DateTime; $date = $token['created_at']->toDateTime();
$date->setTimestamp($token['created_at']->sec);
$token['created_at'] = $date->format('Y-m-d H:i:s'); $token['created_at'] = $date->format('Y-m-d H:i:s');
} }
......
...@@ -19,7 +19,9 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe ...@@ -19,7 +19,9 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe
// interface, and is responsible for the actual storing of auth tokens and // interface, and is responsible for the actual storing of auth tokens and
// their e-mail addresses. We will inject this table and hash key to it. // their e-mail addresses. We will inject this table and hash key to it.
$table = $app['config']['auth.password.table']; $table = $app['config']['auth.password.table'];
$key = $app['config']['app.key']; $key = $app['config']['app.key'];
$expire = $app['config']->get('auth.password.expire', 60); $expire = $app['config']->get('auth.password.expire', 60);
return new DbRepository($connection, $table, $key, $expire); return new DbRepository($connection, $table, $key, $expire);
......
...@@ -43,7 +43,7 @@ class AuthTest extends TestCase { ...@@ -43,7 +43,7 @@ class AuthTest extends TestCase {
$reminder = DB::collection('password_resets')->first(); $reminder = DB::collection('password_resets')->first();
$this->assertEquals('john@doe.com', $reminder['email']); $this->assertEquals('john@doe.com', $reminder['email']);
$this->assertNotNull($reminder['token']); $this->assertNotNull($reminder['token']);
$this->assertInstanceOf('MongoDate', $reminder['created_at']); $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $reminder['created_at']);
$credentials = [ $credentials = [
'email' => 'john@doe.com', 'email' => 'john@doe.com',
......
<?php <?php
use \Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent; use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlBook extends Eloquent { class MysqlBook extends Eloquent {
use HybridRelations;
protected $connection = 'mysql'; protected $connection = 'mysql';
protected $table = 'books'; protected $table = 'books';
protected static $unguarded = true; protected static $unguarded = true;
...@@ -17,7 +19,6 @@ class MysqlBook extends Eloquent { ...@@ -17,7 +19,6 @@ class MysqlBook extends Eloquent {
/** /**
* Check if we need to run the schema. * Check if we need to run the schema.
* @return [type] [description]
*/ */
public static function executeSchema() public static function executeSchema()
{ {
......
<?php <?php
use \Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent; use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlRole extends Eloquent { class MysqlRole extends Eloquent {
use HybridRelations;
protected $connection = 'mysql'; protected $connection = 'mysql';
protected $table = 'roles'; protected $table = 'roles';
protected static $unguarded = true; protected static $unguarded = true;
...@@ -21,7 +23,6 @@ class MysqlRole extends Eloquent { ...@@ -21,7 +23,6 @@ class MysqlRole extends Eloquent {
/** /**
* Check if we need to run the schema. * Check if we need to run the schema.
* @return [type] [description]
*/ */
public static function executeSchema() public static function executeSchema()
{ {
......
<?php <?php
use \Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent; use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlUser extends Eloquent { class MysqlUser extends Eloquent {
use HybridRelations;
protected $connection = 'mysql'; protected $connection = 'mysql';
protected $table = 'users'; protected $table = 'users';
protected static $unguarded = true; protected static $unguarded = true;
...@@ -21,7 +23,6 @@ class MysqlUser extends Eloquent { ...@@ -21,7 +23,6 @@ class MysqlUser extends Eloquent {
/** /**
* Check if we need to run the schema. * Check if we need to run the schema.
* @return [type] [description]
*/ */
public static function executeSchema() public static function executeSchema()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment