Skip to content

Commit

Permalink
Added remember me column and methods
Browse files Browse the repository at this point in the history
Per Laravel 4.1.26 release tightening application security, the users table require a remember me column and methods to set the remember me hash in the DB instead of in the cookie.

Read more at http://laravel.com/docs/upgrade#upgrade-4.1.26
  • Loading branch information
msurguy committed Apr 17, 2014
1 parent 62f2885 commit 7b4815c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/Tricks/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ public function votes()
return $this->belongsToMany('Tricks\Trick', 'votes');
}

/**
* Get the remember me token from DB
*
* @return mixed
*/
public function getRememberToken()
{
return $this->remember_token;
}

/**
* Set the remember me token to DB
*
* @return mixed
*/
public function setRememberToken($value)
{
$this->remember_token = $value;
}

/**
* Get the column of remember me token in DB
*
* @return mixed
*/
public function getRememberTokenName()
{
return 'remember_token';
}

/**
* Get the unique identifier for the user.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddRememberToUserTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function($table)
{
$table->string('remember_token',100)->nullable()->after('id');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function($table)
{
$table->dropColumn('order');
});
}

}

2 comments on commit 7b4815c

@Remo
Copy link
Contributor

@Remo Remo commented on 7b4815c Apr 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this, I just started to work on it 👍

@msurguy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome :)

Please sign in to comment.