ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Ardent + Laravel 4.1.28 User model doesn't update remember_token

Open divdax opened this issue 10 years ago • 6 comments

Hi,

i use the latest Laravel release with ardent. My User model extends Ardent and have some basic rules.

In the latest version of Laravel there is a new column "remember_token" which not gets updated with Ardent, because Eloquent uses the models save() method to update the auth token.

How this can be fixed? Any ideas? :)

divdax avatar Apr 23 '14 15:04 divdax

Here my workaround:

Insert

User::$rules = array();

before Auth::attempt() in the AuthController so Laravel can use the save() method to update the remember_token.

Cheers! :)

divdax avatar Apr 23 '14 15:04 divdax

Hey, thanks for the quick & dirty fix, I happened to stumble upon it right after you posted it :)

I just wanted to note that you also should do that before Auth::logout(), otherwise the remember_me cookie will remain valid.

lan0 avatar Apr 23 '14 15:04 lan0

Thanks @lan0 updatingmycontroller

divdax avatar Apr 23 '14 16:04 divdax

But if SomeModel::rules contains an unique rule,whenever you use somemodel->save() to update the model,it will throw a exception.(Seem to be #86 just can fix it in someway.) Must I use somemodel->UpdateUnique() to avoid it?

caijiong avatar Jul 17 '14 16:07 caijiong

+1 this. Saved so much hair pulling.

Cysioland avatar Jul 24 '14 14:07 Cysioland

This is a terrible hack but it still works. Thank you.

EricWVGG avatar Sep 27 '14 19:09 EricWVGG