refactor: reorganize project structure for better maintainability
- Move 45 debug/test files from root to organized scripts/ directories - Secure public/ directory by removing debug files (security improvement) - Create structured scripts organization: • scripts/debug/ (20 files) - Framework debugging tools • scripts/test/ (18 files) - Test and validation scripts • scripts/maintenance/ (5 files) - Maintenance utilities • scripts/dev/ (2 files) - Development tools Security improvements: - Removed all debug/test files from public/ directory - Only production files remain: index.php, health.php Root directory cleanup: - Reduced from 47 to 2 PHP files in root - Only essential production files: console.php, worker.php This improves: ✅ Security (no debug code in public/) ✅ Organization (clear separation of concerns) ✅ Maintainability (easy to find and manage scripts) ✅ Professional structure (clean root directory)
This commit is contained in:
57
src/Framework/MagicLinks/Actions/EmailVerificationAction.php
Normal file
57
src/Framework/MagicLinks/Actions/EmailVerificationAction.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Smartlinks\Actions;
|
||||
|
||||
use App\Framework\Smartlinks\SmartlinkData;
|
||||
use App\Framework\Smartlinks\TokenConfig;
|
||||
use DateTimeImmutable;
|
||||
|
||||
final readonly class EmailVerificationAction implements SmartlinkAction
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'email_verification';
|
||||
}
|
||||
|
||||
public function getDefaultConfig(): TokenConfig
|
||||
{
|
||||
return new TokenConfig(
|
||||
expiryHours: 24,
|
||||
oneTimeUse: true,
|
||||
maxUses: 1,
|
||||
requireSecureContext: true
|
||||
);
|
||||
}
|
||||
|
||||
public function validatePayload(array $payload): bool
|
||||
{
|
||||
return ! empty($payload['email']) &&
|
||||
! empty($payload['user_id']) &&
|
||||
filter_var($payload['email'], FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
|
||||
public function execute(SmartlinkData $smartlinkData, array $context = []): ActionResult
|
||||
{
|
||||
$payload = $smartlinkData->payload;
|
||||
|
||||
// Email verification logic would go here
|
||||
// For now, just a simple success response
|
||||
|
||||
return ActionResult::success(
|
||||
message: "Email {$payload['email']} successfully verified",
|
||||
data: [
|
||||
'user_id' => $payload['user_id'],
|
||||
'email' => $payload['email'],
|
||||
'verified_at' => new DateTimeImmutable(),
|
||||
],
|
||||
redirectUrl: '/dashboard'
|
||||
);
|
||||
}
|
||||
|
||||
public function getRequiredPermissions(): array
|
||||
{
|
||||
return []; // No special permissions needed for email verification
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user