diff --git a/application/app/Http/Controllers/API/AuthController.php b/application/app/Http/Controllers/API/AuthController.php index 206ef63..870268d 100644 --- a/application/app/Http/Controllers/API/AuthController.php +++ b/application/app/Http/Controllers/API/AuthController.php @@ -71,7 +71,10 @@ public function init(string $publicApiKey, string $authProvider, Request $reques // Handle wallet auth provider if ($authProvider === AuthProviderType::WALLET->value) { // TODO: Handle wallet auth differently - exit('TODO'); + return response()->json([ + 'error' => __('Not Implemented'), + 'reason' => __('Wallet is not supported yet'), + ], 400); } // Handle social auth provider @@ -123,7 +126,7 @@ public function check(string $publicApiKey, Request $request): JsonResponse ); // Check if this request should be geo-blocked - if ($this->isGEOBlocked($project, $request)) { + if ($isAuthenticated && $this->isGEOBlocked($project, $request)) { // Invalidate the isAuthenticated state $isAuthenticated = false; diff --git a/application/config/cors.php b/application/config/cors.php new file mode 100644 index 0000000..005e772 --- /dev/null +++ b/application/config/cors.php @@ -0,0 +1,34 @@ + ['*'], + + 'allowed_methods' => ['*'], + + 'allowed_origins' => ['*'], + + 'allowed_origins_patterns' => [], + + 'allowed_headers' => ['*'], + + 'exposed_headers' => [], + + 'max_age' => 0, + + 'supports_credentials' => false, + +]; diff --git a/application/database/factories/ProjectFactory.php b/application/database/factories/ProjectFactory.php new file mode 100644 index 0000000..a0228d6 --- /dev/null +++ b/application/database/factories/ProjectFactory.php @@ -0,0 +1,28 @@ + + */ +class ProjectFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'user_id' => 0, + 'name' => 'Hydra Doom Testing', + 'public_api_key' => '067d20be-8baa-49cb-b501-e004af358870', + 'private_api_key' => 'f200599d-5d54-4883-b53d-318a00a055e2', + 'geo_blocked_countries' => 'CU, IR, KP, SY, UA', // Cuba, Iran, North Korea, Syria, Ukraine + ]; + } +} diff --git a/application/database/factories/UserFactory.php b/application/database/factories/UserFactory.php index 141237f..a0ab7e2 100644 --- a/application/database/factories/UserFactory.php +++ b/application/database/factories/UserFactory.php @@ -2,12 +2,12 @@ namespace Database\Factories; +use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Str; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User> + * @extends Factory */ class UserFactory extends Factory { diff --git a/application/database/seeders/DatabaseSeeder.php b/application/database/seeders/DatabaseSeeder.php index c3c58ee..14dc5c5 100644 --- a/application/database/seeders/DatabaseSeeder.php +++ b/application/database/seeders/DatabaseSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\Project; use App\Models\User; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -17,11 +18,16 @@ public function run(): void if (app()->environment('local', 'staging')) { // Seed test user - User::factory()->create([ + $user = User::factory()->create([ 'name' => 'Test User', 'email' => 'test@local.dev', ]); + // Seed test project + Project::factory()->create([ + 'user_id' => $user->id, + ]); + } } } diff --git a/application/resources/views/demo.blade.php b/application/resources/views/demo.blade.php new file mode 100644 index 0000000..f914c66 --- /dev/null +++ b/application/resources/views/demo.blade.php @@ -0,0 +1,179 @@ + + + + + + RewardEngine Auth Demo + + + + + + +
+ + + +
+
+ + +
+
+ + +
+ +
+ + + +
+ + + + + diff --git a/application/routes/web.php b/application/routes/web.php index a06f374..5992c93 100644 --- a/application/routes/web.php +++ b/application/routes/web.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Route; Route::get('/', [WelcomeController::class, 'index']); +Route::get('demo', fn() => view('demo')); Route::get('social-auth-callback/{authProvider}', [SocialAuthCallbackController::class, 'handle']); Route::middleware(['auth', 'verified'])->group(static function () {