diff --git a/web/app/Http/Controllers/Auth/RegisteredUserController.php b/web/app/Http/Controllers/Auth/RegisteredUserController.php index 487fedb..131eb43 100644 --- a/web/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/web/app/Http/Controllers/Auth/RegisteredUserController.php @@ -9,10 +9,11 @@ use Illuminate\Auth\Events\Registered; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rules; class RegisteredUserController extends Controller -{ +{ /** * Display the registration view. * @@ -33,14 +34,22 @@ class RegisteredUserController extends Controller */ public function store(Request $request) { - $request->validate([ - 'name' => ['required', 'string', 'max:255'], + $validator = Validator::make($request->all(), [ + 'username' => ['required', 'string', 'min:3', 'max:20', 'regex:/^[a-zA-Z0-9]+[ _.-]?[a-zA-Z0-9]+$/i', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'confirmed', Rules\Password::defaults()], - ]); + ], [ + 'username.min' => 'Username can only be 3 to 20 characters long.', + 'username.max' => 'Username can only be 3 to 20 characters long.', + 'username.regex' => 'Username must be alphanumeric and cannot begin or end with a special character. (a-z, 0-9, dot, hyphen, space, underscores are allowed)' + ]); + + if ($validator->fails()) { + return back()->withErrors($validator)->withInput(); + } $user = User::create([ - 'name' => $request->name, + 'username' => $request->username, 'email' => $request->email, 'password' => Hash::make($request->password), ]); diff --git a/web/app/Models/Banner.php b/web/app/Models/Banner.php new file mode 100644 index 0000000..f007d2b --- /dev/null +++ b/web/app/Models/Banner.php @@ -0,0 +1,11 @@ + */ protected $fillable = [ - 'name', + 'username', 'email', 'password', ]; diff --git a/web/database/factories/UserFactory.php b/web/database/factories/UserFactory.php index 23b61d2..6eb746b 100644 --- a/web/database/factories/UserFactory.php +++ b/web/database/factories/UserFactory.php @@ -18,7 +18,7 @@ class UserFactory extends Factory public function definition() { return [ - 'name' => $this->faker->name(), + 'username' => $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password diff --git a/web/database/migrations/2014_10_12_000000_create_users_table.php b/web/database/migrations/2014_10_12_000000_create_users_table.php index cf6b776..eff9614 100644 --- a/web/database/migrations/2014_10_12_000000_create_users_table.php +++ b/web/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,7 +15,7 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('username')->unique(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); diff --git a/web/database/migrations/2022_04_30_002434_create_banners_table.php b/web/database/migrations/2022_04_30_002434_create_banners_table.php new file mode 100644 index 0000000..27b7e01 --- /dev/null +++ b/web/database/migrations/2022_04_30_002434_create_banners_table.php @@ -0,0 +1,34 @@ +id(); + $table->enum('style', ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']); //https://getbootstrap.com/docs/5.1/components/alerts/ + $table->string('message'); + $table->boolean('dismissable')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('banners'); + } +}; diff --git a/web/database/migrations/2022_04_30_002458_create_dynamic_web_configurations_table.php b/web/database/migrations/2022_04_30_002458_create_dynamic_web_configurations_table.php new file mode 100644 index 0000000..5550aeb --- /dev/null +++ b/web/database/migrations/2022_04_30_002458_create_dynamic_web_configurations_table.php @@ -0,0 +1,31 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('dynamic_web_configurations'); + } +}; diff --git a/web/resources/views/auth/register.blade.php b/web/resources/views/auth/register.blade.php index a0c4fbe..6b3ac22 100644 --- a/web/resources/views/auth/register.blade.php +++ b/web/resources/views/auth/register.blade.php @@ -12,11 +12,11 @@