diff --git a/app/Http/Livewire/Auth/Passwords/Confirm.php b/app/Http/Livewire/Auth/Passwords/Confirm.php
deleted file mode 100644
index c25da5d..0000000
--- a/app/Http/Livewire/Auth/Passwords/Confirm.php
+++ /dev/null
@@ -1,27 +0,0 @@
-validate([
- 'password' => 'required|password',
- ]);
-
- session()->put('auth.password_confirmed_at', time());
-
- redirect()->intended(route('home'));
- }
-
- public function render()
- {
- return view('livewire.auth.passwords.confirm');
- }
-}
diff --git a/app/Http/Livewire/Auth/Register/Individual.php b/app/Http/Livewire/Auth/Register/Individual.php
index d33971b..17e7dcb 100644
--- a/app/Http/Livewire/Auth/Register/Individual.php
+++ b/app/Http/Livewire/Auth/Register/Individual.php
@@ -5,6 +5,8 @@ namespace App\Http\Livewire\Auth\Register;
use App\Providers\RouteServiceProvider;
use App\User;
use App\UserCategory;
+use App\UserNature;
+use App\UserType;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
@@ -36,13 +38,18 @@ class Individual extends Component
'email' => ['required', 'email', 'unique:users'],
]);
- $user = User::create([
+ $user = new User([
'name' => $this->name,
'email' => $this->email,
- 'category_id' => UserCategory::where('key', 'individual')->first()->id,
'birthday' => Carbon::createFromFormat('d/m/Y', $this->birthday),
]);
+ $user->user_category_id = UserCategory::where('key', 'individual')->first()->id;
+ $user->user_nature_id = UserNature::where('key', 'individual')->first()->id;
+ $user->user_type_id = UserType::where('key', 'individual')->first()->id;
+
+ $user->save();
+
Auth::login($user, true);
redirect(route('home'));
diff --git a/app/Http/Livewire/Auth/Verify.php b/app/Http/Livewire/Auth/Verify.php
deleted file mode 100644
index e31c553..0000000
--- a/app/Http/Livewire/Auth/Verify.php
+++ /dev/null
@@ -1,28 +0,0 @@
-hasVerifiedEmail()) {
- redirect(route('home'));
- }
-
- Auth::user()->sendEmailVerificationNotification();
-
- $this->emit('resent');
-
- session()->flash('resent');
- }
-
- public function render()
- {
- return view('livewire.auth.verify');
- }
-}
diff --git a/app/User.php b/app/User.php
index b5e7566..172456f 100644
--- a/app/User.php
+++ b/app/User.php
@@ -16,7 +16,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
- 'name', 'email', 'password', 'category_id', 'birthday'
+ 'name', 'email', 'password', 'birthday'
];
/**
diff --git a/app/UserCategory.php b/app/UserCategory.php
index 39b0b81..8851253 100644
--- a/app/UserCategory.php
+++ b/app/UserCategory.php
@@ -15,16 +15,16 @@ class UserCategory extends Model
'name' => 'Associado Indivíduo',
],
[
- 'key' => 'company',
- 'name' => 'Associada Empresa Apoiadora',
+ 'key' => 'supporting-institution',
+ 'name' => 'Associada Instituição Apoiadora',
],
[
'key' => 'acting-institution',
'name' => 'Associada Instituição Atuante',
],
[
- 'key' => 'supporting-institution',
- 'name' => 'Associada Instituição Apoiadora',
+ 'key' => 'company',
+ 'name' => 'Associada Empresa Apoiadora',
],
];
}
diff --git a/app/UserNature.php b/app/UserNature.php
new file mode 100644
index 0000000..67b48df
--- /dev/null
+++ b/app/UserNature.php
@@ -0,0 +1,26 @@
+ 'individual',
+ 'name' => 'Pessoa Física',
+ ],
+ [
+ 'key' => 'informal',
+ 'name' => 'Coletivo Informal',
+ ],
+ [
+ 'key' => 'company',
+ 'name' => 'Pessoa Jurídica',
+ ]
+ ];
+}
diff --git a/app/UserType.php b/app/UserType.php
new file mode 100644
index 0000000..9d0b820
--- /dev/null
+++ b/app/UserType.php
@@ -0,0 +1,30 @@
+ 'individual',
+ 'name' => 'Indivíduo',
+ ],
+ [
+ 'key' => 'collective',
+ 'name' => 'Coletivo Informal',
+ ],
+ [
+ 'key' => 'association',
+ 'name' => 'Associação Formal',
+ ],
+ [
+ 'key' => 'company',
+ 'name' => 'Empresa Privada',
+ ],
+ ];
+}
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index 9acf160..eccb7c6 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -4,6 +4,8 @@
use App\User;
use App\UserCategory;
+use App\UserNature;
+use App\UserType;
use Carbon\Carbon;
use Faker\Generator as Faker;
use Illuminate\Support\Str;
@@ -24,7 +26,9 @@ $factory->define(User::class, function (Faker $faker) {
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
- 'category_id' => UserCategory::where('key', 'individual')->first()->id,
+ 'user_category_id' => UserCategory::where('key', 'individual')->first()->id,
+ 'user_nature_id' => UserNature::where('key', 'individual')->first()->id,
+ 'user_type_id' => UserType::where('key', 'individual')->first()->id,
'birthday' => Carbon::createFromFormat('d/m/Y', $faker->date('d/m/Y')),
'remember_token' => Str::random(10),
];
diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php
index b52e9b6..1360f55 100644
--- a/database/migrations/2014_10_12_000000_create_users_table.php
+++ b/database/migrations/2014_10_12_000000_create_users_table.php
@@ -20,9 +20,9 @@ class CreateUsersTable extends Migration
$table->string('password');
// User profile
- $table->foreignId('category_id');
-// $table->foreignId('nature_id');
-// $table->foreignId('type_id');
+ $table->foreignId('user_category_id');
+ $table->foreignId('user_nature_id');
+ $table->foreignId('user_type_id');
// $table->string('avatar')->nullable();
$table->date('birthday');
// $table->json('document')->nullable();
diff --git a/resources/views/auth/passwords/confirm.blade.php b/resources/views/auth/passwords/confirm.blade.php
deleted file mode 100644
index 0f39ec7..0000000
--- a/resources/views/auth/passwords/confirm.blade.php
+++ /dev/null
@@ -1,8 +0,0 @@
-@extends('layouts.auth')
-@section('title', 'Confirm your password')
-
-@section('content')
-
- @livewire('auth.passwords.confirm')
-
-@endsection
diff --git a/resources/views/auth/verify.blade.php b/resources/views/auth/verify.blade.php
deleted file mode 100644
index a4128b6..0000000
--- a/resources/views/auth/verify.blade.php
+++ /dev/null
@@ -1,8 +0,0 @@
-@extends('layouts.auth')
-@section('title', 'Verify your email address')
-
-@section('content')
-
- @livewire('auth.verify')
-
-@endsection
diff --git a/resources/views/livewire/auth/passwords/confirm.blade.php b/resources/views/livewire/auth/passwords/confirm.blade.php
deleted file mode 100644
index 6978697..0000000
--- a/resources/views/livewire/auth/passwords/confirm.blade.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
- Please confirm your password before continuing
-
-
-
-
-
diff --git a/resources/views/livewire/auth/verify.blade.php b/resources/views/livewire/auth/verify.blade.php
deleted file mode 100644
index 6904b35..0000000
--- a/resources/views/livewire/auth/verify.blade.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
- @if (session('resent'))
-
-
-
-
A fresh verification link has been sent to your email address.
-
- @endif
-
-
-
Before proceeding, please check your email for a verification link.
-
-
- If you did not receive the email, click here to request another.
-
-
-
-
-
diff --git a/routes/web.php b/routes/web.php
index 6208a22..009b4af 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -25,10 +25,5 @@ Route::view('password/reset', 'auth.passwords.email')->name('password.request');
Route::get('password/reset/{token}', 'Auth\PasswordResetController')->name('password.reset');
Route::middleware('auth')->group(function () {
- Route::view('email/verify', 'auth.verify')->middleware('throttle:6,1')->name('verification.notice');
- Route::get('email/verify/{id}/{hash}', 'Auth\EmailVerificationController')->middleware('signed')->name('verification.verify');
-
Route::post('logout', 'Auth\LogoutController')->name('logout');
-
- Route::view('password/confirm', 'auth.passwords.confirm')->name('password.confirm');
});
diff --git a/tests/Feature/Auth/LoginTest.php b/tests/Feature/Auth/LoginTest.php
index 62ec2a0..b1b06ef 100644
--- a/tests/Feature/Auth/LoginTest.php
+++ b/tests/Feature/Auth/LoginTest.php
@@ -35,7 +35,7 @@ class LoginTest extends TestCase
/** @test */
public function a_user_can_login()
{
- $user = factory(User::class)->create(['password' => Hash::make('password')]);
+ $user = $this->factoryWithoutObservers(User::class)->create(['password' => Hash::make('password')]);
Livewire::test('auth.login')
->set('email', $user->email)
@@ -48,7 +48,7 @@ class LoginTest extends TestCase
/** @test */
public function is_redirected_to_the_home_page_after_login()
{
- $user = factory(User::class)->create(['password' => Hash::make('password')]);
+ $user = $this->factoryWithoutObservers(User::class)->create(['password' => Hash::make('password')]);
Livewire::test('auth.login')
->set('email', $user->email)
diff --git a/tests/Feature/Auth/Passwords/ConfirmTest.php b/tests/Feature/Auth/Passwords/ConfirmTest.php
deleted file mode 100644
index bc1e886..0000000
--- a/tests/Feature/Auth/Passwords/ConfirmTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-middleware(['web', 'password.confirm']);
- }
-
- /** @test */
- public function a_user_must_confirm_their_password_before_visiting_a_protected_page()
- {
- $user = factory(User::class)->create();
- $this->be($user);
-
- $this->get('/must-be-confirmed')
- ->assertRedirect(route('password.confirm'));
-
- $this->followingRedirects()
- ->get('/must-be-confirmed')
- ->assertSeeLivewire('auth.passwords.confirm');
- }
-
- /** @test */
- public function a_user_must_enter_a_password_to_confirm_it()
- {
- Livewire::test('auth.passwords.confirm')
- ->call('confirm')
- ->assertHasErrors(['password' => 'required']);
- }
-
- /** @test */
- public function a_user_must_enter_their_own_password_to_confirm_it()
- {
- $user = factory(User::class)->create([
- 'password' => Hash::make('password'),
- ]);
-
- Livewire::test('auth.passwords.confirm')
- ->set('password', 'not-password')
- ->call('confirm')
- ->assertHasErrors(['password' => 'password']);
- }
-
- /** @test */
- public function a_user_who_confirms_their_password_will_get_redirected()
- {
- $user = factory(User::class)->create([
- 'password' => Hash::make('password'),
- ]);
-
- $this->be($user);
-
- $this->withSession(['url.intended' => '/must-be-confirmed']);
-
- Livewire::test('auth.passwords.confirm')
- ->set('password', 'password')
- ->call('confirm')
- ->assertRedirect('/must-be-confirmed');
- }
-}
diff --git a/tests/Feature/Auth/VerifyTest.php b/tests/Feature/Auth/VerifyTest.php
deleted file mode 100644
index 202ec94..0000000
--- a/tests/Feature/Auth/VerifyTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-create([
- 'email_verified_at' => null,
- ]);
-
- Auth::login($user);
-
- $this->get(route('verification.notice'))
- ->assertSuccessful()
- ->assertSeeLivewire('auth.verify');
- }
-
- /** @test */
- public function can_resend_verification_email()
- {
- $user = factory(User::class)->create();
-
- Livewire::actingAs($user);
-
- Livewire::test('auth.verify')
- ->call('resend')
- ->assertEmitted('resent');
- }
-
- /** @test */
- public function can_verify()
- {
- $user = factory(User::class)->create([
- 'email_verified_at' => null,
- ]);
-
- Auth::login($user);
-
- $url = URL::temporarySignedRoute('verification.verify', Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), [
- 'id' => $user->getKey(),
- 'hash' => sha1($user->getEmailForVerification()),
- ]);
-
- $this->get($url)
- ->assertRedirect(route('home'));
-
- $this->assertTrue($user->hasVerifiedEmail());
- }
-}
diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php
deleted file mode 100644
index d6e5dac..0000000
--- a/tests/Feature/ExampleTest.php
+++ /dev/null
@@ -1,18 +0,0 @@
-get(route('home'))->assertSuccessful();
- }
-}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index a6faa1b..33f5825 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -20,4 +20,12 @@ abstract class TestCase extends BaseTestCase
return '';
});
}
+
+ /**
+ * Create a model factory and forget observers so events do not trigger actions.
+ */
+ public function factoryWithoutObservers($class, $name = 'default') {
+ $class::flushEventListeners();
+ return factory($class, $name);
+ }
}