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

User must implement Remindable interface. #37

Closed
craigward opened this issue Sep 10, 2013 · 17 comments
Closed

User must implement Remindable interface. #37

craigward opened this issue Sep 10, 2013 · 17 comments

Comments

@craigward
Copy link

I am using the inbuilt User auth in Laravel and when storing a password reset via Password::reset I am getting the following error "User must implement Remindable interface." Even though I am implementing that interface.

It was working with MySql, so it must be something I have done when transferring to use your package.

Have you run into this problem before?

@jenssegers
Copy link
Contributor

Could you show some code? You can also email it if you prefer.

@craigward
Copy link
Author

Here is the model in question

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends MongoModel implements UserInterface, RemindableInterface {

/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'administrators';

/**
 * The attributes excluded from the model's JSON form.
 *
 * @var array
 */
protected $hidden = array('password');

/**
 * Get the unique identifier for the user.
 *
 * @return mixed
 */
public function getAuthIdentifier()
{
    return $this->getKey();
}

/**
 * Get the password for the user.
 *
 * @return string
 */
public function getAuthPassword()
{
    return $this->password;
}

/**
 * Get the e-mail address where password reminders are sent.
 *
 * @return string
 */
public function getReminderEmail()
{
    return $this->email;
}

}

I have an Alias set up for MongoModel. Its the standard User model that is shipped with laravel really

@jenssegers
Copy link
Contributor

I added the interfaces to the user model I use in the tests, but I did not get the error.

@craigward
Copy link
Author

How odd, I'll have a dig round and see if it could be anything else.

Thanks for looking

@craigward
Copy link
Author

In the Auth config file should I be using 'Eloquent' or 'database' as the driver?

If I use Eloquent I get a different error, which is: Trying to get property of non-object on line 109 of vendor/laravel/framework/src/Illuminate/Auth/Reminders/DatabaseReminderRepository.php

 $createdPlusHour = strtotime($reminder->created_at) + $this->expires; 

I think this is because the date is now an array which it is not expecting.

@RSully
Copy link

RSully commented Sep 11, 2013

For authentication I am using eloquent, and in my database config I have mongo setup as the default connection which Eloquent should use.

Edit: I haven't tested password resets yet

@craigward
Copy link
Author

The problem with using the Eloquent driver is its throws the error I wrote about above.

@craigward
Copy link
Author

I've added a question on Stack Overflow to see if I can get to the bottom of the issue. Once I do I'll post back here

http://stackoverflow.com/questions/18750824/laravel-and-mongodb-generating-must-implement-remindable-interface

@jenssegers
Copy link
Contributor

I will try it out in a laravel application to see if I get the same error.

@philipzaengle
Copy link

Running into this issue here as well, digging in unless someone has found a solution...

@jenssegers
Copy link
Contributor

What features are you guys using from Auth? I created a user and logged in using Auth::attempt and did not see any errors.

@philipzaengle
Copy link

The error I am experiencing is with Password::reset

@jenssegers
Copy link
Contributor

I'm not getting this error. This is the header of my user model:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Jenssegers\Mongodb\Model as Eloquent;

class User extends Eloquent implements UserInterface, RemindableInterface {

Everything else remains unchanged. The auth driver is set (by default) to 'eloquent'.

@philipzaengle
Copy link

Are you using the standard password_reminders table (in this case a collection)? My issues are in the DatabaseReminderRepository class in namespace Illuminate\Auth\Reminders on line 110 there's a check to see if the reminder has expired, which is unable to perform due to the nature of the data being passed to it via $reminder->created_at.

Ugly core hack, change line 110:
$createdPlusHour = strtotime($reminder->created_at) + $this->expires;
to
$createdPlusHour = strtotime($reminder['created_at']['date'] + $reminder['created_at']['timezone']) + $this->expires;

@jenssegers
Copy link
Contributor

Oh, I was looking at line 216.

I don't really know how to fix the issue with the date object. @philipzaengle, could you try this for me:

$createdPlusHour = strtotime((string) $reminder->created_at) + $this->expires;

@jenssegers
Copy link
Contributor

Never mind, the toString method of the MongoDate class does not return a nice date string.

@jenssegers
Copy link
Contributor

I fixed the password reminder issue. Check out the Auth section in the readme: https://github.com/jenssegers/Laravel-MongoDB#auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants