Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"require": {
"ext-curl": "*",
"ext-json": "*",
"neuron-php/mvc": "0.9.*",
"neuron-php/mvc": "^0.9.5",
"neuron-php/cli": "0.8.*",
"neuron-php/jobs": "0.2.*",
"neuron-php/orm": "0.1.*",
"neuron-php/dto": "0.0.*",
"phpmailer/phpmailer": "^6.9"
},
"require-dev": {
Expand Down
10 changes: 5 additions & 5 deletions resources/app/Initializers/AuthInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Initializers;

use Neuron\Cms\Auth\AuthManager;
use Neuron\Cms\Services\Auth\Authentication;
use Neuron\Cms\Auth\Filters\AuthenticationFilter;
use Neuron\Cms\Auth\PasswordHasher;
use Neuron\Cms\Auth\SessionManager;
Expand Down Expand Up @@ -55,16 +55,16 @@ public function run( array $argv = [] ): mixed
$userRepository = new DatabaseUserRepository( $settings );
$sessionManager = new SessionManager();
$passwordHasher = new PasswordHasher();
$authManager = new AuthManager( $userRepository, $sessionManager, $passwordHasher );
$authentication = new Authentication( $userRepository, $sessionManager, $passwordHasher );

// Create authentication filter
$authFilter = new AuthenticationFilter( $authManager, '/login' );
$authFilter = new AuthenticationFilter( $authentication, '/login' );

// Register the auth filter with the Router
$app->getRouter()->registerFilter( 'auth', $authFilter );

// Store AuthManager in Registry for easy access
Registry::getInstance()->set( 'AuthManager', $authManager );
// Store Authentication in Registry for easy access
Registry::getInstance()->set( 'Authentication', $authentication );
}
}
catch( \Exception $e )
Expand Down
14 changes: 7 additions & 7 deletions resources/app/Initializers/PasswordResetInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Initializers;

use Neuron\Cms\Auth\PasswordHasher;
use Neuron\Cms\Auth\PasswordResetManager;
use Neuron\Cms\Services\Auth\PasswordResetter;
use Neuron\Cms\Repositories\DatabasePasswordResetTokenRepository;
use Neuron\Cms\Repositories\DatabaseUserRepository;
use Neuron\Data\Setting\SettingManager;
Expand All @@ -14,7 +14,7 @@
/**
* Initialize the password reset system
*
* Registers the PasswordResetManager in the Registry
* Registers the PasswordResetter in the Registry
*/
class PasswordResetInitializer implements IRunnable
{
Expand Down Expand Up @@ -59,8 +59,8 @@ public function run( array $argv = [] ): mixed
// Create password reset URL
$resetUrl = rtrim( $siteUrl, '/' ) . '/reset-password';

// Create password reset manager
$resetManager = new PasswordResetManager(
// Create password reset service
$passwordResetter = new PasswordResetter(
$tokenRepository,
$userRepository,
$passwordHasher,
Expand All @@ -70,10 +70,10 @@ public function run( array $argv = [] ): mixed
);

// Set token expiration if configured
$resetManager->setTokenExpirationMinutes( (int)$tokenExpiration );
$passwordResetter->setTokenExpirationMinutes( (int)$tokenExpiration );

// Store PasswordResetManager in Registry for easy access
Registry::getInstance()->set( 'PasswordResetManager', $resetManager );
// Store PasswordResetter in Registry for easy access
Registry::getInstance()->set( 'PasswordResetter', $passwordResetter );
}
}
catch( \Exception $e )
Expand Down
26 changes: 12 additions & 14 deletions resources/app/Initializers/RegistrationInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Initializers;

use Neuron\Cms\Auth\EmailVerificationManager;
use Neuron\Cms\Services\Auth\EmailVerifier;
use Neuron\Cms\Auth\Filters\MemberAuthenticationFilter;
use Neuron\Cms\Auth\AuthManager;
use Neuron\Cms\Services\Auth\Authentication;
use Neuron\Cms\Auth\PasswordHasher;
use Neuron\Cms\Repositories\DatabaseEmailVerificationTokenRepository;
use Neuron\Cms\Repositories\DatabaseUserRepository;
Expand Down Expand Up @@ -46,12 +46,12 @@ public function run( array $argv = [] ): mixed
return null;
}

// Get AuthManager from Registry (must be initialized first by AuthInitializer)
$authManager = Registry::getInstance()->get( 'AuthManager' );
// Get Authentication from Registry (must be initialized first by AuthInitializer)
$authentication = Registry::getInstance()->get( 'Authentication' );

if( !$authManager )
if( !$authentication )
{
Log::error( "AuthManager not found in Registry, skipping registration initialization" );
Log::error( "Authentication not found in Registry, skipping registration initialization" );
return null;
}

Expand All @@ -75,8 +75,8 @@ public function run( array $argv = [] ): mixed
$verificationPath = $settings->get( 'member', 'verification_url' ) ?? '/verify-email';
$verificationUrl = rtrim( $siteUrl, '/' ) . '/' . ltrim( $verificationPath, '/' );

// Create EmailVerificationManager
$verificationManager = new EmailVerificationManager(
// Create EmailVerifier
$emailVerifier = new EmailVerifier(
$tokenRepository,
$userRepository,
$settings,
Expand All @@ -86,7 +86,7 @@ public function run( array $argv = [] ): mixed

// Set token expiration from settings
$tokenExpiration = $settings->get( 'member', 'verification_token_expiration_minutes' ) ?? 60;
$verificationManager->setTokenExpirationMinutes( $tokenExpiration );
$emailVerifier->setTokenExpirationMinutes( $tokenExpiration );

// Get event emitter if available
$emitter = Registry::getInstance()->get( 'EventEmitter' );
Expand All @@ -95,15 +95,15 @@ public function run( array $argv = [] ): mixed
$registrationService = new RegistrationService(
$userRepository,
$passwordHasher,
$verificationManager,
$emailVerifier,
$settings,
$emitter
);

// Create member authentication filter
$requireVerification = $settings->get( 'member', 'require_email_verification' ) ?? true;
$memberFilter = new MemberAuthenticationFilter(
$authManager,
$authentication,
'/login',
$requireVerification
);
Expand All @@ -112,10 +112,8 @@ public function run( array $argv = [] ): mixed
$app->getRouter()->registerFilter( 'member', $memberFilter );

// Store services in Registry for easy access
Registry::getInstance()->set( 'EmailVerificationManager', $verificationManager );
Registry::getInstance()->set( 'EmailVerifier', $emailVerifier );
Registry::getInstance()->set( 'RegistrationService', $registrationService );

Log::info( "Registration system initialized successfully" );
}
}
catch( \Exception $e )
Expand Down
4 changes: 2 additions & 2 deletions resources/app/Initializers/ViewDataInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function run( array $argv = [] ): mixed

// Check if user is authenticated (convenience helper)
$provider->share( 'isAuthenticated', function() use ( $registry ) {
$authManager = $registry->get( 'AuthManager' );
return $authManager && $authManager->check();
$authentication = $registry->get( 'Authentication' );
return $authentication && $authentication->check();
});

return null;
Expand Down
47 changes: 9 additions & 38 deletions resources/views/admin/profile/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,42 +49,15 @@
<div class="mb-3">
<label for="timezone" class="form-label">Timezone</label>
<select class="form-select" id="timezone" name="timezone">
<?php
$currentTimezone = $User->getTimezone();
$grouped = [];

// Group timezones by region
$grouped['Other'] = [];
foreach( $timezones as $timezone )
{
$parts = explode( '/', $timezone, 2 );
if( count( $parts ) === 2 )
{
$region = $parts[0];
if( !isset( $grouped[$region] ) )
{
$grouped[$region] = [];
}
$grouped[$region][] = $timezone;
}
else
{
$grouped['Other'][] = $timezone;
}
}

// Display grouped timezones
foreach( $grouped as $region => $tzList )
{
echo '<optgroup label="' . htmlspecialchars( $region ) . '">';
foreach( $tzList as $timezone )
{
$selected = $timezone === $currentTimezone ? ' selected' : '';
echo '<option value="' . htmlspecialchars( $timezone ) . '"' . $selected . '>' . htmlspecialchars( $timezone ) . '</option>';
}
echo '</optgroup>';
}
?>
<?php foreach( $groupedTimezones as $region => $timezones ): ?>
<optgroup label="<?= htmlspecialchars( $region ) ?>">
<?php foreach( $timezones as $tz ): ?>
<option value="<?= htmlspecialchars( $tz['value'] ) ?>" <?= $tz['selected'] ? 'selected' : '' ?>>
<?= htmlspecialchars( $tz['label'] ) ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
<small class="form-text text-muted">All dates and times will be displayed in your selected timezone</small>
</div>
Expand All @@ -110,8 +83,6 @@
<input type="hidden" name="_method" value="PUT">
<?= csrf_field() ?>

<input type="hidden" name="email" value="<?= htmlspecialchars( $User->getEmail() ) ?>">

<div class="mb-3">
<label for="current_password" class="form-label">Current Password</label>
<input type="password" class="form-control" id="current_password" name="current_password">
Expand Down
3 changes: 1 addition & 2 deletions resources/views/layouts/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.7/dist/<?= htmlspecialchars($theme) ?>/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
Comment thread
ljonesfl marked this conversation as resolved.
</head>
<body class="pb-5">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top" role="navigation">
Expand Down
52 changes: 0 additions & 52 deletions resources/views/member/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,4 @@
<h1 class="mb-4">Member Dashboard</h1>
</div>
</div>

<div class="row mt-4">
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">
<i class="bi bi-person-circle me-2"></i>Profile
</h5>
<p class="card-text">Manage your account settings and personal information.</p>
<a href="<?= route_path('member_profile') ?>" class="btn btn-primary btn-sm">
Edit Profile
</a>
</div>
</div>
</div>

<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">
<i class="bi bi-shield-check me-2"></i>Account Status
</h5>
<p class="card-text">
<strong>Username:</strong> <?= htmlspecialchars( $User->getUsername() ) ?><br>
<strong>Email:</strong> <?= htmlspecialchars( $User->getEmail() ) ?><br>
<strong>Status:</strong>
<?php if( $User->isEmailVerified() ): ?>
<span class="badge bg-success">Verified</span>
<?php else: ?>
<span class="badge bg-warning">Unverified</span>
<?php endif; ?>
</p>
</div>
</div>
</div>

<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">
<i class="bi bi-clock-history me-2"></i>Account Info
</h5>
<p class="card-text">
<strong>Member Since:</strong>
<?= $User->getCreatedAt() ? $User->getCreatedAt()->format('F j, Y') : 'N/A' ?><br>
<strong>Last Login:</strong>
<?= $User->getLastLoginAt() ? $User->getLastLoginAt()->format('F j, Y g:i A') : 'Never' ?>
</p>
</div>
</div>
</div>
</div>
</div>
Loading