Commit ad2e69b1 authored by Jens Segers's avatar Jens Segers

Adding support for mongodb password reminders, fixes #37

parent ad9dc568
...@@ -127,6 +127,15 @@ Supported operations are: ...@@ -127,6 +127,15 @@ Supported operations are:
Read more about the schema builder on http://laravel.com/docs/schema Read more about the schema builder on http://laravel.com/docs/schema
Auth
----
If you want to use Laravel's native Auth functionality, register this included service provider:
'Jenssegers\Mongodb\Auth\ReminderServiceProvider',
This service provider will slightly modify the internal DatabaseReminderRepository to add support for MongoDB based password reminders. If you don't use password reminders, you don't have to register this service provider and everything else should work just fine.
Sessions Sessions
-------- --------
......
<?php namespace Jenssegers\Mongodb\Auth;
class DatabaseReminderRepository extends \Illuminate\Auth\Reminders\DatabaseReminderRepository {
/**
* Determine if the reminder has expired.
*
* @param object $reminder
* @return bool
*/
protected function reminderExpired($reminder)
{
// Convert to object so that we can pass it to the parent method
if (is_array($reminder))
{
$reminder = (object) $reminder;
}
// Convert the DateTime object that got saved to MongoDB
if (is_array($reminder->created_at))
{
$reminder->created_at = $reminder->created_at['date'] + $reminder->created_at['timezone'];
}
return parent::reminderExpired($reminder);
}
}
<?php namespace Jenssegers\Mongodb\Auth;
use Jenssegers\Mongodb\Auth\DatabaseReminderRepository as DbRepository;
class ReminderServiceProvider extends \Illuminate\Auth\Reminders\ReminderServiceProvider {
/**
* Register the reminder repository implementation.
*
* @return void
*/
protected function registerReminderRepository()
{
$this->app->bindShared('auth.reminder.repository', function($app)
{
$connection = $app['db']->connection();
// The database reminder repository is an implementation of the reminder repo
// 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.reminder.table'];
$key = $app['config']['app.key'];
$expire = $app['config']->get('auth.reminder.expire', 60);
return new DbRepository($connection, $table, $key, $expire);
});
}
}
...@@ -31,4 +31,4 @@ class MongodbServiceProvider extends ServiceProvider { ...@@ -31,4 +31,4 @@ class MongodbServiceProvider extends ServiceProvider {
}); });
} }
} }
\ No newline at end of file
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