mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
- Updated notification service models to use pointers for boolean fields, allowing for better handling of enabled states. - Introduced helper methods for getting and setting enabled states in notification and auth provider models. - Refactored notification form templates to consolidate event trigger handling, improving code maintainability. - Added SSL verification configuration to the application settings, allowing users to skip SSL verification for outgoing notifications. - Enhanced the notification sending logic to respect the SSL verification setting. - Introduced new migration to alter boolean defaults in the database schema for better compatibility with the updated models. - Added unit tests for email and Rclone service functionalities to ensure reliability.
52 lines
1.9 KiB
Templ
52 lines
1.9 KiB
Templ
package components
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/starfleetcptn/gomft/internal/db"
|
|
)
|
|
|
|
// getProviderIcon returns the appropriate icon for a provider
|
|
func getProviderIcon(provider db.AuthProvider) templ.Component {
|
|
// If provider has a custom icon URL, use it
|
|
if provider.IconURL != "" {
|
|
return templ.Raw(fmt.Sprintf(`<img src="%s" class="w-5 h-5" alt="%s icon" />`, provider.IconURL, provider.Name))
|
|
}
|
|
|
|
// Otherwise fall back to default icons based on type
|
|
switch provider.Type {
|
|
case db.ProviderTypeAuthentik:
|
|
return templ.Raw(`<img src="/static/img/authentik.svg" class="w-5 h-5" alt="Authentik" />`)
|
|
case db.ProviderTypeOIDC:
|
|
return templ.Raw(`<img src="/static/img/oidc.svg" class="w-5 h-5" alt="OIDC" />`)
|
|
case db.ProviderTypeSAML:
|
|
return templ.Raw(`<img src="/static/img/saml.svg" class="w-5 h-5" alt="SAML" />`)
|
|
case db.ProviderTypeOAuth2:
|
|
return templ.Raw(`<img src="/static/img/oauth2.svg" class="w-5 h-5" alt="OAuth2" />`)
|
|
default:
|
|
return templ.Raw(`<i class="fas fa-user-shield text-blue-500"></i>`)
|
|
}
|
|
}
|
|
|
|
templ AuthProviderButtons(providers []db.AuthProvider) {
|
|
if len(providers) == 0 {
|
|
<div class="text-sm text-gray-500 dark:text-gray-400 italic">
|
|
No external authentication providers available
|
|
</div>
|
|
} else {
|
|
<div class="space-y-2 w-full">
|
|
for _, provider := range providers {
|
|
if provider.GetEnabled() {
|
|
<a
|
|
href={ templ.SafeURL(fmt.Sprintf("/auth/provider/%d", provider.ID)) }
|
|
class="w-full inline-flex items-center justify-center px-4 py-2.5 bg-gray-100 border border-gray-300 rounded-lg font-medium text-gray-700 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-600"
|
|
>
|
|
<span class="flex-shrink-0 w-5 h-5 mr-2.5">
|
|
@getProviderIcon(provider)
|
|
</span>
|
|
<span>{ provider.Name }</span>
|
|
</a>
|
|
}
|
|
}
|
|
</div>
|
|
}
|
|
} |