liberu-real-estate / real-estate-laravel

Real Estate / Estate Agent, solution for your Property Agency. Application written in Laravel 11 / PHP 8.3 using Filament 3
https://www.facebook.com/liberusoftware
34 stars 18 forks source link

Sweep: remove auth #79

Closed curtisdelicata closed 6 months ago

curtisdelicata commented 6 months ago

Details

Remove all custom login, register, verification, reset code and add the native filament 3 lines to all the panels for registration, verification, reset and login

Checklist - [X] Modify `routes/landlord.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/95534ca23fdfc0640b9cacb69a55e05c73a05afe [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/routes/landlord.php#L7-L23) - [X] Running GitHub Actions for `routes/landlord.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/routes/landlord.php#L7-L23) - [X] Modify `app/Http/Controllers/Landlord/AuthController.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/536df0a38d3e2a7bd42fe16310c9c17da8ebfafb [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Http/Controllers/Landlord/AuthController.php) - [X] Running GitHub Actions for `app/Http/Controllers/Landlord/AuthController.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Http/Controllers/Landlord/AuthController.php) - [X] Modify `app/Providers/Filament/LandlordPanelProvider.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/b72aaeab6b36a142b63e7c35e46e08f881c08cc5 [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/Filament/LandlordPanelProvider.php#L22-L58) - [X] Running GitHub Actions for `app/Providers/Filament/LandlordPanelProvider.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/Filament/LandlordPanelProvider.php#L22-L58) - [X] Modify `app/Providers/Filament/ContractorPanelProvider.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/4fa45f11e3ff8e63151c868a49a8d13e98512ec2 [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/Filament/ContractorPanelProvider.php#L19-L42) - [X] Running GitHub Actions for `app/Providers/Filament/ContractorPanelProvider.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/Filament/ContractorPanelProvider.php#L19-L42) - [X] Modify `app/Filament/Resources/TenantResource.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/12d2e5d67e9784389d44dff8cd85d3da9e547b4a [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Filament/Resources/TenantResource.php#L58-L85) - [X] Running GitHub Actions for `app/Filament/Resources/TenantResource.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Filament/Resources/TenantResource.php#L58-L85) - [X] Modify `app/Providers/EventServiceProvider.php` ✓ https://github.com/liberu-real-estate/real-estate-laravel/commit/6d9cb4ba6f11c8228ca8e2e87ae6e6e9ed9d8ebb [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/EventServiceProvider.php#L16-L19) - [X] Running GitHub Actions for `app/Providers/EventServiceProvider.php` ✓ [Edit](https://github.com/liberu-real-estate/real-estate-laravel/edit/sweep/remove_auth/app/Providers/EventServiceProvider.php#L16-L19)
sweep-ai[bot] commented 6 months ago

🚀 Here's the PR! #90

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 29317e920d)

[!TIP] I'll email you at genealogysoftwareuk@gmail.com when I complete this pull request!


Actions (click)

GitHub Actions✓

Here are the GitHub Actions logs prior to making any changes:

Sandbox logs for 537ae52
Checking routes/landlord.php for syntax errors... ✅ routes/landlord.php has no syntax errors! 1/1 ✓
Checking routes/landlord.php for syntax errors...
✅ routes/landlord.php has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/routes/landlord.php#L1-L23 https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/app/Filament/Resources/TenantResource.php#L57-L85 https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/app/Http/Controllers/Landlord/AuthController.php#L1-L80 https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/app/Providers/EventServiceProvider.php#L1-L20 https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/app/Providers/Filament/ContractorPanelProvider.php#L1-L44 https://github.com/liberu-real-estate/real-estate-laravel/blob/5d2d99171ff721b6143f28c4347bfd8c0aebbe5e/app/Providers/Filament/LandlordPanelProvider.php#L1-L60

Step 2: ⌨️ Coding

--- 
+++ 
@@ -1,24 +1,3 @@
 <?php

 use Illuminate\Support\Facades\Route;
-use App\Http\Controllers\LandlordAuthController;
-use App\Http\Controllers\LandlordPasswordResetController;
-use App\Http\Controllers\LandlordVerificationController;
-
-// Landlord Registration
-Route::get('/register', [LandlordAuthController::class, 'registerForm'])->name('landlord.register.form');
-Route::post('/register', [LandlordAuthController::class, 'register'])->name('landlord.register');
-
-// Landlord Login
-Route::get('/login', [LandlordAuthController::class, 'loginForm'])->name('landlord.login.form');
-Route::post('/login', [LandlordAuthController::class, 'login'])->name('landlord.login');
-
-// Landlord Password Reset
-Route::get('/password/reset', [LandlordPasswordResetController::class, 'showResetRequestForm'])->name('landlord.password.request');
-Route::post('/password/email', [LandlordPasswordResetController::class, 'sendResetLinkEmail'])->name('landlord.password.email');
-Route::get('/password/reset/{token}', [LandlordPasswordResetController::class, 'showResetForm'])->name('landlord.password.reset.form');
-Route::post('/password/reset', [LandlordPasswordResetController::class, 'reset'])->name('landlord.password.update');
-
-// Landlord Verification
-Route::get('/email/verify', [LandlordVerificationController::class, 'show'])->name('landlord.verification.notice');
-Route::get('/email/verify/{id}/{hash}', [LandlordVerificationController::class, 'verify'])->name('landlord.verification.verify')->middleware(['signed', 'throttle:6,1']);

Ran GitHub Actions for 95534ca23fdfc0640b9cacb69a55e05c73a05afe:

--- 
+++ 
@@ -1,81 +1 @@
-<?php
-
-namespace App\Http\Controllers\Landlord;
-
-use App\Http\Controllers\Controller;
-use App\Providers\RouteServiceProvider;
-use Illuminate\Foundation\Auth\AuthenticatesUsers;
-use Illuminate\Foundation\Auth\RegistersUsers;
-use Illuminate\Foundation\Auth\ResetsPasswords;
-use Illuminate\Foundation\Auth\VerifiesEmails;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Hash;
-use Illuminate\Support\Facades\Password;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Http\Request;
-use Illuminate\Http\RedirectResponse;
-
-class AuthController extends Controller
-{
-    use AuthenticatesUsers, RegistersUsers, ResetsPasswords, VerifiesEmails;
-
-    protected $redirectTo = RouteServiceProvider::HOME;
-
-    public function __construct()
-    {
-        $this->middleware('guest:landlord')->except('logout');
-    }
-
-    protected function guard()
-    {
-        return Auth::guard('landlord');
-    }
-
-    protected function broker()
-    {
-        return Password::broker('landlords');
-    }
-
-    public function showLoginForm()
-    {
-        return view('landlord.auth.login');
-    }
-
-    public function showRegistrationForm()
-    {
-        return view('landlord.auth.register');
-    }
-
-    public function showLinkRequestForm()
-    {
-        return view('landlord.auth.passwords.email');
-    }
-
-    public function showResetForm(Request $request, $token = null)
-    {
-        return view('landlord.auth.passwords.reset')->with(['token' => $token, 'email' => $request->email]);
-    }
-
-    public function showVerificationNotice()
-    {
-        return view('landlord.auth.verify');
-    }
-
-    protected function validator(array $data)
-    {
-        return Validator::make($data, [
-            'name' => ['required', 'string', 'max:255'],
-            'email' => ['required', 'string', 'email', 'max:255', 'unique:landlords'],
-            'password' => ['required', 'string', 'min:8', 'confirmed'],
-        ]);
-    }
-
-    protected function create(array $data)
-    {
-        return Auth::guard('landlord')->create([
-            'name' => $data['name'],
-            'email' => $data['email'],
-            'password' => Hash::make($data['password']),
-        ]);
-    }
-}
+// This file has been emptied in preparation for migration to Filament's native authentication system.

Ran GitHub Actions for 536df0a38d3e2a7bd42fe16310c9c17da8ebfafb:

--- 
+++ 
@@ -26,7 +26,7 @@
             ->default()
             ->id('landlord')
             ->path('landlord')
-            ->login()
+            ->login()->register()->resetPasswords()->verifyEmails()
             ->colors([
                 'primary' => Color::Amber,
             ])

Ran GitHub Actions for b72aaeab6b36a142b63e7c35e46e08f881c08cc5:

--- 
+++ 
@@ -23,7 +23,7 @@
             ->default()
             ->id('contractor')
             ->path('contractor')
-            ->login()
+            ->login()->register()->resetPasswords()->verifyEmails()
             ->discoverResources(in: app_path('Filament/Resources/Contractors'), for: 'App\\Filament\\Resources\\Contractors')
             ->discoverPages(in: app_path('Filament/Pages/Contractors'), for: 'App\\Filament\\Pages\\Contractors')
             ->discoverWidgets(in: app_path('Filament/Widgets/Contractors'), for: 'App\\Filament\\Widgets\\Contractors')

Ran GitHub Actions for 4fa45f11e3ff8e63151c868a49a8d13e98512ec2:

--- 
+++ 
@@ -55,33 +55,33 @@
             ]);
     }

-    protected static function handleLogin(array $data)
-    {
-        if (!Auth::attempt($data)) {
-            throw ValidationException::withMessages([
-                'email' => [__('auth.failed')],
-            ]);
-        }
-    }
+    // protected static function handleLogin(array $data)
+    // {
+    //     if (!Auth::attempt($data)) {
+    //         throw ValidationException::withMessages([
+    //             'email' => [__('auth.failed')],
+    //         ]);
+    //     }
+    // }

-    protected static function handleRegister(array $data)
-    {
-        // Registration logic here
-    }
+    // protected static function handleRegister(array $data)
+    // {
+    //     // Registration logic here
+    // }

-    protected static function handleVerification(array $data)
-    {
-        // Verification logic here
-    }
+    // protected static function handleVerification(array $data)
+    // {
+    //     // Verification logic here
+    // }

-    protected static function handleReset(array $data)
-    {
-        $status = Password::sendResetLink($data);
+    // protected static function handleReset(array $data)
+    // {
+    //     $status = Password::sendResetLink($data);

-        if ($status !== Password::RESET_LINK_SENT) {
-            throw ValidationException::withMessages([
-                'email' => [__($status)],
-            ]);
-        }
-    }
+    //     if ($status !== Password::RESET_LINK_SENT) {
+    //         throw ValidationException::withMessages([
+    //             'email' => [__($status)],
+    //         ]);
+    //     }
+    // }
 }

Ran GitHub Actions for 12d2e5d67e9784389d44dff8cd85d3da9e547b4a:

--- 
+++ 
@@ -15,9 +15,9 @@
      * @var array>
      */
     protected $listen = [
-        Registered::class => [
-            SendEmailVerificationNotification::class,
-        ],
+        // Registered::class => [
+        //     SendEmailVerificationNotification::class,
+        // ],
     ];

     /**

Ran GitHub Actions for 6d9cb4ba6f11c8228ca8e2e87ae6e6e9ed9d8ebb:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/remove_auth.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.

This is an automated message generated by Sweep AI.