diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 566e51df295635c8ee9a94561210ff20529a5288..1b29aa2cdb0a937741cfe87044ea7301d95dd7dc 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 9738772de1e210093ed9214aebd2cc31d619b939..efde7e8f030b6b5e71a2f260c4c6d2866e5767da 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(); } } diff --git a/app/Models/User.php b/app/Models/User.php index aab3e39d9fcdeaf34d7796cac3a00e7705abe628..5867318b656a6e5bd4ecec7cf3dac29a22e881ab 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/config/fortify.php b/config/fortify.php index 726d83bb0f9876a6954db7d0de30b31745a38631..d2f31e3e6758551c94bc64c407daa9d9d5c2c960 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -45,7 +45,7 @@ | */ - 'username' => 'email', + 'username' => 'username', 'email' => 'email', 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 31d7807237dc3426e4c19160fe4bb4d52a71f52a..4eb7892aaa23b4357e4cf6392e41d6617a118748 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(); diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index ba780c267039e0ef0d3349f1565094e6630fe907..74e53e901f2513f64a2b17c0f1864bd1b783d5e1 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'); diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 5d7134376e730738bfc3eeb404421825acd6c45a..d486b64dcc2f0a0e1858aa9c9635ac2afb0e43cd 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -16,8 +16,8 @@ @csrf