Commit ca8c74ce authored by Jens Segers's avatar Jens Segers

Fix and re-enable tests for auth

parent 315b84e2
<?php namespace Jenssegers\Mongodb\Auth;
use DateTime;
use MongoDate;
use Carbon\Carbon;
use MongoDB\BSON\UTCDateTime;
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository {
......@@ -14,7 +14,7 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe
*/
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
*/
protected function tokenExpired($token)
{
// Convert MongoDate to a date string.
if ($token['created_at'] instanceof MongoDate)
// Convert UTCDateTime to a date string.
if ($token['created_at'] instanceof UTCDateTime)
{
$date = new DateTime;
$date->setTimestamp($token['created_at']->sec);
$date = $token['created_at']->toDateTime();
$token['created_at'] = $date->format('Y-m-d H:i:s');
}
......
......@@ -19,7 +19,9 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe
// 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.
$table = $app['config']['auth.password.table'];
$key = $app['config']['app.key'];
$expire = $app['config']->get('auth.password.expire', 60);
return new DbRepository($connection, $table, $key, $expire);
......
......@@ -43,7 +43,7 @@ class AuthTest extends TestCase {
$reminder = DB::collection('password_resets')->first();
$this->assertEquals('john@doe.com', $reminder['email']);
$this->assertNotNull($reminder['token']);
$this->assertInstanceOf('MongoDate', $reminder['created_at']);
$this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $reminder['created_at']);
$credentials = [
'email' => 'john@doe.com',
......
<?php
use \Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent;
use Illuminate\Support\Facades\Schema;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlBook extends Eloquent {
use HybridRelations;
protected $connection = 'mysql';
protected $table = 'books';
protected static $unguarded = true;
......@@ -17,7 +19,6 @@ class MysqlBook extends Eloquent {
/**
* Check if we need to run the schema.
* @return [type] [description]
*/
public static function executeSchema()
{
......
<?php
use \Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent;
use Illuminate\Support\Facades\Schema;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlRole extends Eloquent {
use HybridRelations;
protected $connection = 'mysql';
protected $table = 'roles';
protected static $unguarded = true;
......@@ -21,7 +23,6 @@ class MysqlRole extends Eloquent {
/**
* Check if we need to run the schema.
* @return [type] [description]
*/
public static function executeSchema()
{
......
<?php
use \Illuminate\Support\Facades\Schema;
use Jenssegers\Eloquent\Model as Eloquent;
use Illuminate\Support\Facades\Schema;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
class MysqlUser extends Eloquent {
use HybridRelations;
protected $connection = 'mysql';
protected $table = 'users';
protected static $unguarded = true;
......@@ -21,7 +23,6 @@ class MysqlUser extends Eloquent {
/**
* Check if we need to run the schema.
* @return [type] [description]
*/
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