Add PWA support with install banner and app icons
All checks were successful
Build And Push Image / docker (push) Successful in 2m56s
All checks were successful
Build And Push Image / docker (push) Successful in 2m56s
- Configure @vite-pwa/nuxt module with manifest and service worker - Add PWA install banner component to login page - Include app icons (192x192, 512x512) and favicon assets - Update admin dashboard layout and remove backup section - Add PWA-related API endpoints and utility scripts
This commit is contained in:
@@ -94,20 +94,53 @@ export default defineEventHandler(async (event) => {
|
||||
console.log('👤 Found user:', { id: userId, email: users[0].email });
|
||||
|
||||
// Send reset password email using Keycloak's execute-actions-email
|
||||
const resetResponse = await fetch(`${adminBaseUrl}/users/${userId}/execute-actions-email`, {
|
||||
// Add query parameters for better email template rendering
|
||||
const resetUrl = new URL(`${adminBaseUrl}/users/${userId}/execute-actions-email`);
|
||||
resetUrl.searchParams.set('clientId', config.keycloak.clientId);
|
||||
resetUrl.searchParams.set('redirectUri', `${config.keycloak.callbackUrl.replace('/auth/callback', '/login')}`);
|
||||
resetUrl.searchParams.set('lifespan', '43200'); // 12 hours
|
||||
|
||||
console.log('🔄 Sending password reset email with parameters:', {
|
||||
clientId: config.keycloak.clientId,
|
||||
redirectUri: resetUrl.searchParams.get('redirectUri'),
|
||||
lifespan: resetUrl.searchParams.get('lifespan')
|
||||
});
|
||||
|
||||
// Create AbortController for timeout handling
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 30000); // 30 second timeout
|
||||
|
||||
const resetResponse = await fetch(resetUrl.toString(), {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${adminToken.access_token}`,
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'MonacoUSA-Portal/1.0'
|
||||
},
|
||||
body: JSON.stringify(['UPDATE_PASSWORD'])
|
||||
body: JSON.stringify(['UPDATE_PASSWORD']),
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (!resetResponse.ok) {
|
||||
console.error('❌ Failed to send reset email:', resetResponse.status);
|
||||
const errorText = await resetResponse.text().catch(() => 'Unknown error');
|
||||
console.error('Reset email error details:', errorText);
|
||||
|
||||
// Enhanced error handling for different scenarios
|
||||
if (resetResponse.status === 500) {
|
||||
console.error('🚨 SMTP server error detected - this usually indicates email configuration issues in Keycloak');
|
||||
console.error('💡 Suggestion: Check Keycloak Admin Console → Realm Settings → Email tab');
|
||||
|
||||
// For now, still return success to user for security, but log the issue
|
||||
console.log('🔄 Returning success message to user despite email failure for security');
|
||||
return {
|
||||
success: true,
|
||||
message: 'If the email exists in our system, a reset link has been sent. If you don\'t receive an email, please contact your administrator.'
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error('Failed to send reset email');
|
||||
}
|
||||
|
||||
@@ -121,6 +154,24 @@ export default defineEventHandler(async (event) => {
|
||||
} catch (keycloakError: any) {
|
||||
console.error('❌ Keycloak API error:', keycloakError);
|
||||
|
||||
// Handle timeout errors specifically
|
||||
if (keycloakError.name === 'AbortError') {
|
||||
console.error('⏰ Password reset request timed out after 30 seconds');
|
||||
return {
|
||||
success: true,
|
||||
message: 'Password reset request is being processed. If the email exists in our system, a reset link will be sent shortly.'
|
||||
};
|
||||
}
|
||||
|
||||
// Handle SMTP/email server errors
|
||||
if (keycloakError.message?.includes('send reset email') || keycloakError.message?.includes('SMTP')) {
|
||||
console.error('📧 Email server error detected, but user search was successful');
|
||||
return {
|
||||
success: true,
|
||||
message: 'If the email exists in our system, a reset link has been sent. If you don\'t receive an email, please contact your administrator.'
|
||||
};
|
||||
}
|
||||
|
||||
// For security, don't reveal specific errors to the user
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user