Permalink
Browse files

Episode 74

  • Loading branch information...
JeffreyWay committed Aug 29, 2017
1 parent 66c74ef commit 5afff932efa4aecab992bd986739aec39a5be7c9
@@ -65,11 +65,11 @@ protected function validator(array $data)
*/
protected function create(array $data)
{
return User::forceCreate([
User::forceCreate([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'confirmation_token' => str_random(25)
'confirmation_token' => str_limit(md5($data['email'] . str_random()), 25, '')
]);
}
@@ -88,6 +88,7 @@ public function activity()
public function confirm()
{
$this->confirmed = true;
$this->confirmation_token = null;
$this->save();
}
@@ -20,7 +20,7 @@ public function up()
$table->string('password');
$table->string('avatar_path')->nullable();
$table->boolean('confirmed')->default(false);
$table->string('confirmation_token', 25)->nullable();
$table->string('confirmation_token', 25)->nullable()->unique();
$table->rememberToken();
$table->timestamps();
});
@@ -12,7 +12,6 @@
*/
Route::get('/', function () {
\Mail::to(App\User::first())->send(new \App\Mail\PleaseConfirmYourEmail());
return view('welcome');
});
@@ -13,7 +13,7 @@ class RegistrationTest extends TestCase
use DatabaseMigrations;
/** @test */
public function a_confirmation_email_is_sent_upon_registration()
function a_confirmation_email_is_sent_upon_registration()
{
Mail::fake();
@@ -47,7 +47,10 @@ function user_can_fully_confirm_their_email_addresses()
$this->get(route('register.confirm', ['token' => $user->confirmation_token]))
->assertRedirect(route('threads'));
$this->assertTrue($user->fresh()->confirmed);
tap($user->fresh(), function ($user) {
$this->assertTrue($user->confirmed);
$this->assertNull($user->confirmation_token);
});
}
/** @test */

0 comments on commit 5afff93

Please sign in to comment.