From 798e0426995a7eade45c13db45a2a564a7e63ede Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 3 Jun 2024 21:22:57 -0600 Subject: [PATCH 1/5] Ajuste de modelo para agregar usuario y si esta activo --- app/Models/User.php | 4 +++- database/migrations/0001_01_01_000000_create_users_table.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index aab3e39..5867318 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -27,7 +27,9 @@ class User extends Authenticatable */ protected $fillable = [ 'name', - 'email', + //'email', + 'username', + 'active', 'password', ]; diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 31d7807..4eb7892 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -14,9 +14,10 @@ public function up(): void Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); - $table->string('email')->unique(); + $table->string('username')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); + $table->boolean('active')->default(0); $table->rememberToken(); $table->foreignId('current_team_id')->nullable(); $table->string('profile_photo_path', 2048)->nullable(); -- GitLab From d73dbe245c01f300d520c67177881f79f07050c1 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 3 Jun 2024 21:23:22 -0600 Subject: [PATCH 2/5] Se cambio la variable email por username --- config/fortify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/fortify.php b/config/fortify.php index 726d83b..d2f31e3 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -45,7 +45,7 @@ | */ - 'username' => 'email', + 'username' => 'username', 'email' => 'email', -- GitLab From d85ca0051851f99429548b49b97f3433d2c2f5bf Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 3 Jun 2024 21:23:47 -0600 Subject: [PATCH 3/5] Validaciones para guardar y editar un perfil --- app/Actions/Fortify/CreateNewUser.php | 4 ++-- app/Actions/Fortify/UpdateUserProfileInformation.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 566e51d..1b29aa2 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -21,14 +21,14 @@ public function create(array $input): User { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'username' => ['required', 'string', 'max:255', 'min:4', 'unique:users'], 'password' => $this->passwordRules(), 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '', ])->validate(); return User::create([ 'name' => $input['name'], - 'email' => $input['email'], + 'username' => $input['username'], 'password' => Hash::make($input['password']), ]); } diff --git a/app/Actions/Fortify/UpdateUserProfileInformation.php b/app/Actions/Fortify/UpdateUserProfileInformation.php index 9738772..efde7e8 100644 --- a/app/Actions/Fortify/UpdateUserProfileInformation.php +++ b/app/Actions/Fortify/UpdateUserProfileInformation.php @@ -19,7 +19,7 @@ public function update(User $user, array $input): void { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], + 'username' => ['required', 'min:4', 'max:255', Rule::unique('users')->ignore($user->id)], 'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'], ])->validateWithBag('updateProfileInformation'); @@ -33,7 +33,7 @@ public function update(User $user, array $input): void } else { $user->forceFill([ 'name' => $input['name'], - 'email' => $input['email'], + 'username' => $input['username'], ])->save(); } } -- GitLab From 30519f2a1b20033b7348415c51161a1273acf228 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 3 Jun 2024 21:24:08 -0600 Subject: [PATCH 4/5] =?UTF-8?q?Modificaci=C3=B3n=20de=20los=20datos=20del?= =?UTF-8?q?=20seeder=20para=20login=20con=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/UserSeeder.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index ba780c2..74e53e9 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -24,28 +24,32 @@ public function run(): void $user = User::create([ 'name' => 'Administración general', - 'email' => 'admin@admin.com', + 'username' => 'admingen', + 'active' => 1, 'password' => Hash::make('12345678'), ]); $user->assignRole('admingen'); $user = User::create([ 'name' => 'Administración', - 'email' => 'admin2@admin.com', + 'username' => 'admin', + 'active' => 1, 'password' => Hash::make('12345678'), ]); $user->assignRole('admin'); $user = User::create([ 'name' => 'Capturista', - 'email' => 'cap@cap.com', + 'username' => 'capturista', + 'active' => 1, 'password' => Hash::make('12345678'), ]); $user->assignRole('capturista'); $user = User::create([ 'name' => 'Lector', - 'email' => 'lec@lec.com', + 'username' => 'lector', + 'active' => 1, 'password' => Hash::make('12345678'), ]); $user->assignRole('lector'); -- GitLab From 8b63344923936137d9274a2c4e71a7894000ea08 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 3 Jun 2024 21:24:22 -0600 Subject: [PATCH 5/5] Vistas actualizadas para utilizar el usuario --- resources/views/auth/login.blade.php | 4 ++-- .../views/profile/update-profile-information-form.blade.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 5d71343..d486b64 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -16,8 +16,8 @@ @csrf
- - + +
diff --git a/resources/views/profile/update-profile-information-form.blade.php b/resources/views/profile/update-profile-information-form.blade.php index cd61010..8bad6d7 100644 --- a/resources/views/profile/update-profile-information-form.blade.php +++ b/resources/views/profile/update-profile-information-form.blade.php @@ -61,9 +61,9 @@
- - - + + + @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::emailVerification()) && ! $this->user->hasVerifiedEmail())

-- GitLab