handlers

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AuthLoginAttemptsTotal counts login attempts by result.
	AuthLoginAttemptsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_login_attempts_total",
			Help: "Total number of login attempts.",
		},
		[]string{"result"},
	)

	// AuthTokenRefreshTotal counts token refresh attempts by result.
	AuthTokenRefreshTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_token_refresh_total",
			Help: "Total number of token refresh attempts.",
		},
		[]string{"result"},
	)

	// Auth2FAAttemptsTotal counts 2FA verification attempts by result.
	Auth2FAAttemptsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_2fa_attempts_total",
			Help: "Total number of 2FA verification attempts.",
		},
		[]string{"result"},
	)

	// OIDCLoginAttemptsTotal counts steps of the OIDC login flow by result.
	// Zero on deployments that do not use OIDC. A rising invalid_state or
	// email_conflict rate is the signal an operator needs when a provider is
	// misconfigured, since the browser only ever sees a coarse error code.
	OIDCLoginAttemptsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_oidc_login_attempts_total",
			Help: "Total number of OIDC login flow steps by result.",
		},
		[]string{"result"},
	)
)

Functions

func FrontendBaseURL added in v1.3.2

func FrontendBaseURL() string

FrontendBaseURL resolves the canonical frontend origin used to build links embedded in outbound emails (verification, password reset, signature requests, ...). Mirrors the FRONTEND_URL -> CORS_ORIGIN -> localhost fallback chain used ad hoc elsewhere; CORS_ORIGIN may contain multiple comma-separated origins, so only the first is used.

Exported so background workers, which build the same links without a request in hand, resolve the origin the same way rather than reimplementing the fallback chain.

func RegisterCurrencyRoutes

func RegisterCurrencyRoutes(api *gin.RouterGroup, h *APIHandler)

RegisterCurrencyRoutes registers the currency status endpoint

func RegisterCustomCurrencyRoutes added in v1.3.1

func RegisterCustomCurrencyRoutes(api *gin.RouterGroup, h *CustomCurrencyHandler)

RegisterCustomCurrencyRoutes wires the custom currency routes onto the group.

func RegisterFlightUtilRoutes

func RegisterFlightUtilRoutes(api *gin.RouterGroup, h *APIHandler)

RegisterFlightUtilRoutes registers utility routes for flights

func RegisterOIDCRoutes added in v1.3.2

func RegisterOIDCRoutes(rg *gin.RouterGroup, h *APIHandler)

RegisterOIDCRoutes registers the two browser-facing OIDC endpoints.

These are redirects driven by top-level navigation, not JSON operations, so they are wired manually rather than through the generated ServerInterface — the same treatment the reports and flight-utility routes get. The two JSON endpoints of the flow (/auth/providers and /auth/oidc/exchange) are in the OpenAPI spec and generated normally.

func RegisterReportsRoutes

func RegisterReportsRoutes(api *gin.RouterGroup, h *APIHandler, db *sql.DB)

RegisterReportsRoutes kept for backward compat; routes now via generated interface.

func StartImportSessionReaper added in v1.3.1

func StartImportSessionReaper(ctx context.Context, interval time.Duration)

StartImportSessionReaper evicts expired upload sessions on a timer. Cleanup previously ran only at the start of the next upload, so an attacker who stopped uploading left everything resident until someone else uploaded.

Types

type APIHandler

type APIHandler struct {
	// contains filtered or unexported fields
}

APIHandler implements the generated.ServerInterface from OpenAPI spec

func NewAPIHandler

func NewAPIHandler(
	authService *service.AuthService,
	licenseService *service.LicenseService,
	flightService *service.FlightService,
	credentialService *service.CredentialService,
	aircraftService *service.AircraftService,
	notificationService *service.NotificationService,
	twoFactorService *service.TwoFactorService,
	contactService *service.ContactService,
	classRatingService *service.ClassRatingService,
	currencyService *currency.Service,
	webauthnService *service.WebAuthnService,
	jwtManager *jwt.Manager,
	flightCrewRepo repository.FlightCrewRepository,
	adminEmail string,
) *APIHandler

NewAPIHandler creates a new unified API handler that implements the OpenAPI ServerInterface

func (*APIHandler) AttachCrewMembers added in v1.2.4

func (h *APIHandler) AttachCrewMembers(ctx context.Context, flights []*models.Flight)

AttachCrewMembers is the exported wrapper used by the cloud-backup JSON builder so it can reuse the same crew enrichment pathway as the HTTP export handler.

func (*APIHandler) ChangePassword

func (h *APIHandler) ChangePassword(c *gin.Context)

ChangePassword implements POST /auth/change-password (POST /auth/change-password)

func (*APIHandler) CleanupTokens

func (h *APIHandler) CleanupTokens(c *gin.Context)

CleanupTokens implements POST /admin/maintenance/cleanup-tokens

func (*APIHandler) CleanupUnverifiedAccounts added in v1.3.2

func (h *APIHandler) CleanupUnverifiedAccounts(c *gin.Context)

CleanupUnverifiedAccounts implements POST /admin/maintenance/cleanup-unverified

func (*APIHandler) CompletePublicSignature added in v1.2.9

func (h *APIHandler) CompletePublicSignature(c *gin.Context, token generated.SignatureToken)

CompletePublicSignature implements POST /sign/{token}

func (*APIHandler) ConfirmImport

func (h *APIHandler) ConfirmImport(c *gin.Context)

ConfirmImport implements POST /imports/confirm

func (*APIHandler) CreateAircraft

func (h *APIHandler) CreateAircraft(c *gin.Context)

CreateAircraft implements POST /aircraft (POST /aircraft)

func (*APIHandler) CreateAnnouncement

func (h *APIHandler) CreateAnnouncement(c *gin.Context)

CreateAnnouncement implements POST /admin/announcements

func (*APIHandler) CreateBackupDestination added in v1.2.4

func (h *APIHandler) CreateBackupDestination(c *gin.Context)

CreateBackupDestination wires up a new destination for the current user.

func (*APIHandler) CreateClassRating

func (h *APIHandler) CreateClassRating(c *gin.Context, licenseId generated.LicenseId)

func (*APIHandler) CreateContact

func (h *APIHandler) CreateContact(c *gin.Context)

CreateContact handles POST /contacts

func (*APIHandler) CreateCredential

func (h *APIHandler) CreateCredential(c *gin.Context)

CreateCredential implements POST /credentials

func (*APIHandler) CreateFlight

func (h *APIHandler) CreateFlight(c *gin.Context)

CreateFlight implements POST /flights (POST /flights)

func (*APIHandler) CreateLicense

func (h *APIHandler) CreateLicense(c *gin.Context)

CreateLicense implements POST /licenses (POST /licenses)

func (*APIHandler) CreateSignatureRequest added in v1.2.9

func (h *APIHandler) CreateSignatureRequest(c *gin.Context, flightId generated.FlightId)

CreateSignatureRequest implements POST /flights/{flightId}/signatures

func (*APIHandler) DeleteAircraft

func (h *APIHandler) DeleteAircraft(c *gin.Context, aircraftId generated.AircraftId)

DeleteAircraft implements DELETE /aircraft/{aircraftId} (DELETE /aircraft/{aircraftId})

func (*APIHandler) DeleteAllFlights

func (h *APIHandler) DeleteAllFlights(c *gin.Context)

DeleteAllFlights implements DELETE /flights/delete-all

func (*APIHandler) DeleteAllUserData

func (h *APIHandler) DeleteAllUserData(c *gin.Context)

DeleteAllUserData implements DELETE /users/me/data

func (*APIHandler) DeleteAnnouncement

func (h *APIHandler) DeleteAnnouncement(c *gin.Context, announcementId openapi_types.UUID)

DeleteAnnouncement implements DELETE /admin/announcements/{announcementId}

func (*APIHandler) DeleteBackupDestination added in v1.2.4

func (h *APIHandler) DeleteBackupDestination(c *gin.Context, destinationID generated.BackupDestinationId)

DeleteBackupDestination removes a destination.

func (*APIHandler) DeleteClassRating

func (h *APIHandler) DeleteClassRating(c *gin.Context, licenseId generated.LicenseId, ratingId openapi_types.UUID)

func (*APIHandler) DeleteContact

func (h *APIHandler) DeleteContact(c *gin.Context, contactId openapi_types.UUID)

DeleteContact handles DELETE /contacts/{contactId}

func (*APIHandler) DeleteCredential

func (h *APIHandler) DeleteCredential(c *gin.Context, credentialId generated.CredentialId)

DeleteCredential implements DELETE /credentials/{credentialId}

func (*APIHandler) DeleteCredentialFile added in v1.3.2

func (h *APIHandler) DeleteCredentialFile(c *gin.Context, credentialId generated.CredentialId, fileId generated.DocumentFileId)

DeleteCredentialFile implements DELETE /credentials/{credentialId}/files/{fileId}

func (*APIHandler) DeleteCurrentUser

func (h *APIHandler) DeleteCurrentUser(c *gin.Context)

DeleteCurrentUser implements DELETE /users/me (DELETE /users/me)

func (*APIHandler) DeleteEmailSuppression added in v1.3.2

func (h *APIHandler) DeleteEmailSuppression(c *gin.Context, email openapi_types.Email)

DeleteEmailSuppression implements DELETE /admin/email/suppressions/{email}

func (*APIHandler) DeleteFlight

func (h *APIHandler) DeleteFlight(c *gin.Context, flightId generated.FlightId)

DeleteFlight implements DELETE /flights/{flightId} (DELETE /flights/{flightId})

func (*APIHandler) DeleteLicense

func (h *APIHandler) DeleteLicense(c *gin.Context, licenseId generated.LicenseId)

DeleteLicense implements DELETE /licenses/{licenseId} (DELETE /licenses/{licenseId})

func (*APIHandler) DeleteLicenseFile added in v1.3.2

func (h *APIHandler) DeleteLicenseFile(c *gin.Context, licenseId generated.LicenseId, fileId generated.DocumentFileId)

DeleteLicenseFile implements DELETE /licenses/{licenseId}/files/{fileId}

func (*APIHandler) DeleteMyBaseline added in v1.2.3

func (h *APIHandler) DeleteMyBaseline(c *gin.Context)

DeleteMyBaseline implements DELETE /users/me/baseline.

func (*APIHandler) DeleteUser added in v1.2.3

func (h *APIHandler) DeleteUser(c *gin.Context, userId openapi_types.UUID)

DeleteUser implements DELETE /admin/users/{userId} Permanently deletes a user and all of their content via FK ON DELETE CASCADE.

func (*APIHandler) DeleteWebauthnCredential added in v1.2.0

func (h *APIHandler) DeleteWebauthnCredential(c *gin.Context, credentialId openapi_types.UUID)

DeleteWebauthnCredential implements DELETE /auth/webauthn/credentials/{credentialId}

func (*APIHandler) Disable2FA

func (h *APIHandler) Disable2FA(c *gin.Context)

Disable2FA implements POST /auth/2fa/disable

func (*APIHandler) DisableUser

func (h *APIHandler) DisableUser(c *gin.Context, userId openapi_types.UUID)

DisableUser implements POST /admin/users/{userId}/disable

func (*APIHandler) DiscardCurrentFlightSession added in v1.2.8

func (h *APIHandler) DiscardCurrentFlightSession(c *gin.Context)

DiscardCurrentFlightSession implements DELETE /flight-sessions/current (DELETE /flight-sessions/current)

func (*APIHandler) EnableUser

func (h *APIHandler) EnableUser(c *gin.Context, userId openapi_types.UUID)

EnableUser implements POST /admin/users/{userId}/enable

func (*APIHandler) ExchangeOidcCode added in v1.3.2

func (h *APIHandler) ExchangeOidcCode(c *gin.Context)

ExchangeOidcCode implements POST /auth/oidc/exchange

func (*APIHandler) ExportDataJSON

func (h *APIHandler) ExportDataJSON(c *gin.Context)

ExportDataJSON implements GET /exports/json

func (*APIHandler) ExportFlightsCSV

func (h *APIHandler) ExportFlightsCSV(c *gin.Context, params generated.ExportFlightsCSVParams)

ExportFlightsCSV implements GET /exports/csv

func (*APIHandler) ExportFlightsPDF

func (h *APIHandler) ExportFlightsPDF(c *gin.Context, params generated.ExportFlightsPDFParams)

ExportFlightsPDF implements GET /exports/pdf

func (*APIHandler) GetAdminConfig

func (h *APIHandler) GetAdminConfig(c *gin.Context)

GetAdminConfig implements GET /admin/config

func (*APIHandler) GetAdminStats

func (h *APIHandler) GetAdminStats(c *gin.Context)

GetAdminStats implements GET /admin/stats

func (*APIHandler) GetAircraft

func (h *APIHandler) GetAircraft(c *gin.Context, aircraftId generated.AircraftId)

GetAircraft implements GET /aircraft/{aircraftId} (GET /aircraft/{aircraftId})

func (*APIHandler) GetAircraftStats added in v1.3.1

func (h *APIHandler) GetAircraftStats(c *gin.Context)

GetAircraftStats implements GET /aircraft/stats (GET /aircraft/stats)

func (*APIHandler) GetAirport

func (h *APIHandler) GetAirport(c *gin.Context, icaoCode string)

GetAirport implements GET /airports/{icaoCode}

func (*APIHandler) GetAirportStats

func (h *APIHandler) GetAirportStats(c *gin.Context)

GetAirportStats implements GET /reports/airport-stats

func (*APIHandler) GetAllCurrencyStatus

func (h *APIHandler) GetAllCurrencyStatus(c *gin.Context)

GetAllCurrencyStatus returns currency status for all class ratings across all licenses

func (*APIHandler) GetAnnouncements

func (h *APIHandler) GetAnnouncements(c *gin.Context)

GetAnnouncements implements GET /announcements Returns active system announcements + auto-generated user hints

func (*APIHandler) GetAuthProviders added in v1.3.2

func (h *APIHandler) GetAuthProviders(c *gin.Context)

GetAuthProviders implements GET /auth/providers

Unauthenticated on purpose: the client has to know which sign-in UI to draw before anyone can log in. It exposes only which methods exist, never the issuer's client secret or any account data.

func (*APIHandler) GetBackupDestination added in v1.2.4

func (h *APIHandler) GetBackupDestination(c *gin.Context, destinationID generated.BackupDestinationId)

GetBackupDestination returns one destination by ID.

func (*APIHandler) GetBackupRun added in v1.2.4

func (h *APIHandler) GetBackupRun(c *gin.Context, runID openapi_types.UUID)

GetBackupRun returns a single run scoped to the calling user.

func (*APIHandler) GetContact

func (h *APIHandler) GetContact(c *gin.Context, contactId openapi_types.UUID)

GetContact handles GET /contacts/{contactId}

func (*APIHandler) GetCredential

func (h *APIHandler) GetCredential(c *gin.Context, credentialId generated.CredentialId)

GetCredential implements GET /credentials/{credentialId}

func (*APIHandler) GetCredentialFile added in v1.3.2

func (h *APIHandler) GetCredentialFile(c *gin.Context, credentialId generated.CredentialId, fileId generated.DocumentFileId)

GetCredentialFile implements GET /credentials/{credentialId}/files/{fileId}

func (*APIHandler) GetCurrentFlightSession added in v1.2.8

func (h *APIHandler) GetCurrentFlightSession(c *gin.Context)

GetCurrentFlightSession implements GET /flight-sessions/current (GET /flight-sessions/current)

func (*APIHandler) GetCurrentUser

func (h *APIHandler) GetCurrentUser(c *gin.Context)

GetCurrentUser implements GET /users/me (GET /users/me)

func (*APIHandler) GetFeatures added in v1.3.2

func (h *APIHandler) GetFeatures(c *gin.Context)

GetFeatures implements GET /features — the capability probe a client uses to decide whether to render the image UI at all.

func (*APIHandler) GetFlight

func (h *APIHandler) GetFlight(c *gin.Context, flightId generated.FlightId)

GetFlight implements GET /flights/{flightId} (GET /flights/{flightId})

func (*APIHandler) GetFlightAnalytics added in v1.3.1

func (h *APIHandler) GetFlightAnalytics(c *gin.Context, params generated.GetFlightAnalyticsParams)

GetFlightAnalytics implements GET /reports/analytics

func (*APIHandler) GetFlightRoutes

func (h *APIHandler) GetFlightRoutes(c *gin.Context)

GetFlightRoutes implements GET /reports/routes

func (*APIHandler) GetFlightSignature added in v1.2.9

func (h *APIHandler) GetFlightSignature(c *gin.Context, flightId generated.FlightId, signatureId generated.SignatureId)

GetFlightSignature implements GET /flights/{flightId}/signatures/{signatureId}

func (*APIHandler) GetFlightSignatureImage added in v1.2.9

func (h *APIHandler) GetFlightSignatureImage(c *gin.Context, flightId generated.FlightId, signatureId generated.SignatureId)

GetFlightSignatureImage implements GET /flights/{flightId}/signatures/{signatureId}/image

func (*APIHandler) GetFlightTrends

func (h *APIHandler) GetFlightTrends(c *gin.Context, params generated.GetFlightTrendsParams)

GetFlightTrends implements GET /reports/trends

func (*APIHandler) GetImport

func (h *APIHandler) GetImport(c *gin.Context, importId generated.ImportId)

GetImport implements GET /imports/{importId}

func (*APIHandler) GetLicense

func (h *APIHandler) GetLicense(c *gin.Context, licenseId generated.LicenseId)

GetLicense implements GET /licenses/{licenseId} (GET /licenses/{licenseId})

func (*APIHandler) GetLicenseCurrency

func (h *APIHandler) GetLicenseCurrency(c *gin.Context, licenseId generated.LicenseId)

GetLicenseCurrency implements GET /licenses/{licenseId}/currency (GET /licenses/{licenseId}/currency)

func (*APIHandler) GetLicenseFile added in v1.3.2

func (h *APIHandler) GetLicenseFile(c *gin.Context, licenseId generated.LicenseId, fileId generated.DocumentFileId)

GetLicenseFile implements GET /licenses/{licenseId}/files/{fileId}

func (*APIHandler) GetLicenseStatistics

func (h *APIHandler) GetLicenseStatistics(c *gin.Context, licenseId generated.LicenseId, params generated.GetLicenseStatisticsParams)

GetLicenseStatistics implements GET /licenses/{licenseId}/statistics (GET /licenses/{licenseId}/statistics)

func (*APIHandler) GetMyBaseline added in v1.2.3

func (h *APIHandler) GetMyBaseline(c *gin.Context)

GetMyBaseline implements GET /users/me/baseline.

func (*APIHandler) GetMyStatistics

func (h *APIHandler) GetMyStatistics(c *gin.Context, params generated.GetMyStatisticsParams)

GetMyStatistics implements GET /users/me/statistics

func (*APIHandler) GetNotificationHistory

func (h *APIHandler) GetNotificationHistory(c *gin.Context, params generated.GetNotificationHistoryParams)

GetNotificationHistory implements GET /users/me/notifications/history

func (*APIHandler) GetNotificationPreferences

func (h *APIHandler) GetNotificationPreferences(c *gin.Context)

GetNotificationPreferences implements GET /users/me/notifications

func (*APIHandler) GetPublicSignatureInfo added in v1.2.9

func (h *APIHandler) GetPublicSignatureInfo(c *gin.Context, token generated.SignatureToken)

GetPublicSignatureInfo implements GET /sign/{token}

func (*APIHandler) GetStatsByClass

func (h *APIHandler) GetStatsByClass(c *gin.Context, params generated.GetStatsByClassParams)

GetStatsByClass implements GET /reports/stats-by-class

func (*APIHandler) ImportDataJSON added in v1.2.3

func (h *APIHandler) ImportDataJSON(c *gin.Context)

ImportDataJSON implements POST /imports/json. It restores a NinerLog JSON backup (as produced by GET /exports/json) into the authenticated user's account. All entity IDs are regenerated so a backup can be restored into any installation, including the one it was exported from. The operation is additive: existing user data is never touched, and aircraft whose registration already exists for the user are skipped (their existing IDs are referenced by imported flights via aircraftReg, no remapping needed).

func (*APIHandler) ListAdminAuditLog

func (h *APIHandler) ListAdminAuditLog(c *gin.Context, params generated.ListAdminAuditLogParams)

ListAdminAuditLog implements GET /admin/audit-log

func (*APIHandler) ListAdminUsers

func (h *APIHandler) ListAdminUsers(c *gin.Context, params generated.ListAdminUsersParams)

ListAdminUsers implements GET /admin/users

func (*APIHandler) ListAircraft

func (h *APIHandler) ListAircraft(c *gin.Context, params generated.ListAircraftParams)

ListAircraft implements GET /aircraft (GET /aircraft)

func (*APIHandler) ListBackupDestinations added in v1.2.4

func (h *APIHandler) ListBackupDestinations(c *gin.Context)

ListBackupDestinations returns the user's configured destinations.

func (*APIHandler) ListBackupProviders added in v1.2.4

func (h *APIHandler) ListBackupProviders(c *gin.Context)

ListBackupProviders returns the static catalog of registered providers.

func (*APIHandler) ListBackupRuns added in v1.2.4

func (h *APIHandler) ListBackupRuns(c *gin.Context, destinationID generated.BackupDestinationId, params generated.ListBackupRunsParams)

ListBackupRuns returns paginated audit log entries.

func (*APIHandler) ListClassRatings

func (h *APIHandler) ListClassRatings(c *gin.Context, licenseId generated.LicenseId)

func (*APIHandler) ListContacts

func (h *APIHandler) ListContacts(c *gin.Context, params generated.ListContactsParams)

ListContacts handles GET /contacts

func (*APIHandler) ListCredentialFiles added in v1.3.2

func (h *APIHandler) ListCredentialFiles(c *gin.Context, credentialId generated.CredentialId)

ListCredentialFiles implements GET /credentials/{credentialId}/files

func (*APIHandler) ListCredentials

func (h *APIHandler) ListCredentials(c *gin.Context, params generated.ListCredentialsParams)

ListCredentials implements GET /credentials

func (*APIHandler) ListDeletions added in v1.3.2

func (h *APIHandler) ListDeletions(c *gin.Context, params generated.ListDeletionsParams)

ListDeletions implements GET /sync/deletions

func (*APIHandler) ListEmailDeliveries added in v1.3.2

func (h *APIHandler) ListEmailDeliveries(c *gin.Context, params generated.ListEmailDeliveriesParams)

ListEmailDeliveries implements GET /admin/email/deliveries

func (*APIHandler) ListEmailSuppressions added in v1.3.2

func (h *APIHandler) ListEmailSuppressions(c *gin.Context, params generated.ListEmailSuppressionsParams)

ListEmailSuppressions implements GET /admin/email/suppressions

func (*APIHandler) ListFlightSignatures added in v1.2.9

func (h *APIHandler) ListFlightSignatures(c *gin.Context, flightId generated.FlightId)

ListFlightSignatures implements GET /flights/{flightId}/signatures

func (*APIHandler) ListFlights

func (h *APIHandler) ListFlights(c *gin.Context, params generated.ListFlightsParams)

ListFlights implements GET /flights (GET /flights)

func (*APIHandler) ListImports

func (h *APIHandler) ListImports(c *gin.Context, params generated.ListImportsParams)

ListImports implements GET /imports

func (*APIHandler) ListLicenseFiles added in v1.3.2

func (h *APIHandler) ListLicenseFiles(c *gin.Context, licenseId generated.LicenseId)

ListLicenseFiles implements GET /licenses/{licenseId}/files

func (*APIHandler) ListLicenses

func (h *APIHandler) ListLicenses(c *gin.Context, params generated.ListLicensesParams)

ListLicenses implements GET /licenses (GET /licenses)

func (*APIHandler) ListWebauthnCredentials added in v1.2.0

func (h *APIHandler) ListWebauthnCredentials(c *gin.Context)

ListWebauthnCredentials implements GET /auth/webauthn/credentials

func (*APIHandler) Login2FA

func (h *APIHandler) Login2FA(c *gin.Context)

Login2FA implements POST /auth/2fa/login

func (*APIHandler) LoginUser

func (h *APIHandler) LoginUser(c *gin.Context)

LoginUser implements POST /auth/login (POST /auth/login)

func (*APIHandler) LogoutUser added in v1.3.1

func (h *APIHandler) LogoutUser(c *gin.Context)

LogoutUser implements POST /auth/logout

Revokes the presented refresh token server-side. Previously no such endpoint existed: AuthService.Logout was implemented but never wired to a route, and the frontend only cleared localStorage. A refresh token therefore stayed valid in the database for its full 7-day lifetime after the user had "logged out", so anyone holding a copy could mint a fresh session at will.

Always answers 204. Revocation is idempotent, and reporting whether a given token existed would leak information to an unauthenticated caller.

func (*APIHandler) OIDCAuthorize added in v1.3.2

func (h *APIHandler) OIDCAuthorize(c *gin.Context)

OIDCAuthorize implements GET /auth/oidc/authorize.

Starts a login: mints the state, nonce and PKCE verifier, plants the browser-binding cookie, and redirects to the provider.

func (*APIHandler) OIDCCallback added in v1.3.2

func (h *APIHandler) OIDCCallback(c *gin.Context)

OIDCCallback implements GET /auth/oidc/callback.

The provider sends the browser here. Everything that can go wrong ends in a redirect back to the frontend carrying a short error code rather than a JSON error page, because the user is looking at a browser window mid-login, not at an API client.

func (*APIHandler) OIDCEnabled added in v1.3.2

func (h *APIHandler) OIDCEnabled() bool

OIDCEnabled reports whether the server runs in OIDC mode.

func (*APIHandler) PreviewImport

func (h *APIHandler) PreviewImport(c *gin.Context)

PreviewImport implements POST /imports/preview

func (*APIHandler) PutMyBaseline added in v1.2.3

func (h *APIHandler) PutMyBaseline(c *gin.Context)

PutMyBaseline implements PUT /users/me/baseline.

func (*APIHandler) RecalculateFlights

func (h *APIHandler) RecalculateFlights(c *gin.Context)

RecalculateFlights recalculates all auto-computed fields for every flight

func (*APIHandler) RecordFlightSessionEvent added in v1.2.8

func (h *APIHandler) RecordFlightSessionEvent(c *gin.Context)

RecordFlightSessionEvent implements POST /flight-sessions/current/events (POST /flight-sessions/current/events)

func (*APIHandler) RefreshToken

func (h *APIHandler) RefreshToken(c *gin.Context)

RefreshToken implements POST /auth/refresh (POST /auth/refresh)

func (*APIHandler) RegisterUser

func (h *APIHandler) RegisterUser(c *gin.Context)

RegisterUser implements POST /auth/register (POST /auth/register)

func (*APIHandler) RequestPasswordReset added in v1.1.0

func (h *APIHandler) RequestPasswordReset(c *gin.Context)

RequestPasswordReset implements POST /auth/password-reset-request (POST /auth/password-reset-request)

func (*APIHandler) ResendSignatureRequest added in v1.2.9

func (h *APIHandler) ResendSignatureRequest(c *gin.Context, flightId generated.FlightId, signatureId generated.SignatureId)

ResendSignatureRequest implements POST /flights/{flightId}/signatures/{signatureId}/resend

func (*APIHandler) ResendVerificationEmail added in v1.2.5

func (h *APIHandler) ResendVerificationEmail(c *gin.Context)

ResendVerificationEmail implements POST /auth/verify-email/resend (POST /auth/verify-email/resend)

func (*APIHandler) ResetPassword added in v1.1.0

func (h *APIHandler) ResetPassword(c *gin.Context)

ResetPassword implements POST /auth/password-reset (POST /auth/password-reset)

A reset does not disable 2FA. An account with 2FA enabled must supply a TOTP or recovery code alongside the reset token, so control of the mailbox alone is not enough to take the account over. Either way the owner is told by mail that their password changed.

func (*APIHandler) ResetUser2fa

func (h *APIHandler) ResetUser2fa(c *gin.Context, userId openapi_types.UUID)

ResetUser2fa implements POST /admin/users/{userId}/reset-2fa

func (*APIHandler) RevokeSignatureRequest added in v1.2.9

func (h *APIHandler) RevokeSignatureRequest(c *gin.Context, flightId generated.FlightId, signatureId generated.SignatureId)

RevokeSignatureRequest implements POST /flights/{flightId}/signatures/{signatureId}/revoke

func (*APIHandler) RunBackupNow added in v1.2.4

func (h *APIHandler) RunBackupNow(c *gin.Context, destinationID generated.BackupDestinationId)

RunBackupNow starts a synchronous backup run.

func (*APIHandler) SearchAirports

func (h *APIHandler) SearchAirports(c *gin.Context, params generated.SearchAirportsParams)

SearchAirports implements GET /airports/search

func (*APIHandler) SearchContacts

func (h *APIHandler) SearchContacts(c *gin.Context, params generated.SearchContactsParams)

SearchContacts handles GET /contacts/search

func (*APIHandler) SetBackupService added in v1.2.4

func (h *APIHandler) SetBackupService(s *cloudbackup.Service)

SetBackupService stores the cloud backup service (optional — only set when BACKUP_CREDENTIALS_KEY is configured at startup).

func (*APIHandler) SetCORSOrigins

func (h *APIHandler) SetCORSOrigins(origins []string)

SetCORSOrigins stores the configured CORS origins for the config endpoint

func (*APIHandler) SetDB

func (h *APIHandler) SetDB(db *sql.DB)

SetDB stores the database reference for direct queries in map handlers

func (*APIHandler) SetDeletionService added in v1.3.2

func (h *APIHandler) SetDeletionService(s *service.DeletionService)

SetDeletionService stores the tombstone feed service.

func (*APIHandler) SetDocumentFileService added in v1.3.2

func (h *APIHandler) SetDocumentFileService(s *service.DocumentFileService)

SetDocumentFileService wires up the licence/credential image subsystem.

func (*APIHandler) SetEmailDeliveryService added in v1.3.2

func (h *APIHandler) SetEmailDeliveryService(s *service.EmailDeliveryService)

SetEmailDeliveryService stores the email delivery log service.

func (*APIHandler) SetEmailSender

func (h *APIHandler) SetEmailSender(sender *email.Sender)

SetEmailSender stores the email sender for admin SMTP test

func (*APIHandler) SetFlightSessionService added in v1.2.8

func (h *APIHandler) SetFlightSessionService(s *service.FlightSessionService)

SetFlightSessionService stores the tap-to-log flight session service

func (*APIHandler) SetFlightSignatureService added in v1.2.9

func (h *APIHandler) SetFlightSignatureService(s *service.FlightSignatureService)

SetFlightSignatureService stores the instructor sign-off service

func (*APIHandler) SetOIDCService added in v1.3.2

func (h *APIHandler) SetOIDCService(s *service.OIDCService)

SetOIDCService stores the OIDC service (optional — only set when OIDC_ISSUER is configured). A non-nil service also disables every local credential endpoint; see requireLocalAuth.

func (*APIHandler) SetStartedAt

func (h *APIHandler) SetStartedAt(t time.Time)

SetStartedAt records the server start time for uptime calculation

func (*APIHandler) SetUnverifiedAccountService added in v1.3.2

func (h *APIHandler) SetUnverifiedAccountService(s *service.UnverifiedAccountService)

SetUnverifiedAccountService stores the unverified-account reaper, so an administrator can run a sweep on demand.

func (*APIHandler) Setup2FA

func (h *APIHandler) Setup2FA(c *gin.Context)

Setup2FA implements POST /auth/2fa/setup

func (*APIHandler) SignFlightLive added in v1.2.9

func (h *APIHandler) SignFlightLive(c *gin.Context, flightId generated.FlightId)

SignFlightLive implements POST /flights/{flightId}/signatures/live

func (*APIHandler) SmtpTest

func (h *APIHandler) SmtpTest(c *gin.Context)

SmtpTest implements POST /admin/maintenance/smtp-test

func (*APIHandler) TestBackupDestination added in v1.2.4

func (h *APIHandler) TestBackupDestination(c *gin.Context, destinationID generated.BackupDestinationId)

TestBackupDestination re-runs the provider validation.

func (*APIHandler) TriggerNotifications

func (h *APIHandler) TriggerNotifications(c *gin.Context)

TriggerNotifications implements POST /admin/maintenance/trigger-notifications

func (*APIHandler) UnlockUser

func (h *APIHandler) UnlockUser(c *gin.Context, userId openapi_types.UUID)

UnlockUser implements POST /admin/users/{userId}/unlock

func (*APIHandler) UpdateAircraft

func (h *APIHandler) UpdateAircraft(c *gin.Context, aircraftId generated.AircraftId)

UpdateAircraft implements PATCH /aircraft/{aircraftId} (PATCH /aircraft/{aircraftId})

func (*APIHandler) UpdateBackupDestination added in v1.2.4

func (h *APIHandler) UpdateBackupDestination(c *gin.Context, destinationID generated.BackupDestinationId)

UpdateBackupDestination applies a partial update.

func (*APIHandler) UpdateClassRating

func (h *APIHandler) UpdateClassRating(c *gin.Context, licenseId generated.LicenseId, ratingId openapi_types.UUID)

func (*APIHandler) UpdateContact

func (h *APIHandler) UpdateContact(c *gin.Context, contactId openapi_types.UUID)

UpdateContact handles PUT /contacts/{contactId}

func (*APIHandler) UpdateCredential

func (h *APIHandler) UpdateCredential(c *gin.Context, credentialId generated.CredentialId)

UpdateCredential implements PATCH /credentials/{credentialId}

func (*APIHandler) UpdateCurrentUser

func (h *APIHandler) UpdateCurrentUser(c *gin.Context)

UpdateCurrentUser implements PATCH /users/me (PATCH /users/me)

func (*APIHandler) UpdateFlight

func (h *APIHandler) UpdateFlight(c *gin.Context, flightId generated.FlightId)

UpdateFlight implements PUT /flights/{flightId} (PUT /flights/{flightId})

func (*APIHandler) UpdateLicense

func (h *APIHandler) UpdateLicense(c *gin.Context, licenseId generated.LicenseId)

UpdateLicense implements PATCH /licenses/{licenseId} (PATCH /licenses/{licenseId})

func (*APIHandler) UpdateNotificationPreferences

func (h *APIHandler) UpdateNotificationPreferences(c *gin.Context)

UpdateNotificationPreferences implements PATCH /users/me/notifications

func (*APIHandler) UploadCredentialFile added in v1.3.2

func (h *APIHandler) UploadCredentialFile(c *gin.Context, credentialId generated.CredentialId)

UploadCredentialFile implements POST /credentials/{credentialId}/files

func (*APIHandler) UploadImportFile

func (h *APIHandler) UploadImportFile(c *gin.Context)

UploadImportFile implements POST /imports/upload

func (*APIHandler) UploadLicenseFile added in v1.3.2

func (h *APIHandler) UploadLicenseFile(c *gin.Context, licenseId generated.LicenseId)

UploadLicenseFile implements POST /licenses/{licenseId}/files

func (*APIHandler) Verify2FA

func (h *APIHandler) Verify2FA(c *gin.Context)

Verify2FA implements POST /auth/2fa/verify

func (*APIHandler) VerifyEmail added in v1.2.5

func (h *APIHandler) VerifyEmail(c *gin.Context)

VerifyEmail implements POST /auth/verify-email (POST /auth/verify-email)

func (*APIHandler) VoidFlightSignature added in v1.2.9

func (h *APIHandler) VoidFlightSignature(c *gin.Context, flightId generated.FlightId, signatureId generated.SignatureId)

VoidFlightSignature implements POST /flights/{flightId}/signatures/{signatureId}/void

func (*APIHandler) WebauthnLoginOptions added in v1.2.0

func (h *APIHandler) WebauthnLoginOptions(c *gin.Context)

WebauthnLoginOptions implements POST /auth/webauthn/login/options

func (*APIHandler) WebauthnLoginVerify added in v1.2.0

func (h *APIHandler) WebauthnLoginVerify(c *gin.Context)

WebauthnLoginVerify implements POST /auth/webauthn/login/verify

func (*APIHandler) WebauthnRegisterOptions added in v1.2.0

func (h *APIHandler) WebauthnRegisterOptions(c *gin.Context)

WebauthnRegisterOptions implements POST /auth/webauthn/register/options

func (*APIHandler) WebauthnRegisterVerify added in v1.2.0

func (h *APIHandler) WebauthnRegisterVerify(c *gin.Context)

WebauthnRegisterVerify implements POST /auth/webauthn/register/verify

type AircraftBreakdown

type AircraftBreakdown struct {
	AircraftType string `json:"aircraftType"`
	TotalFlights int    `json:"totalFlights"`
	TotalMinutes int    `json:"totalMinutes"`
}

AircraftBreakdown represents flight statistics per aircraft type

type CustomCurrencyHandler added in v1.3.1

type CustomCurrencyHandler struct {
	// contains filtered or unexported fields
}

CustomCurrencyHandler serves the user-authored currency rule endpoints. It is self-contained (its own service + auth) and registered on the authenticated /api group, so every route already has a validated userID in context.

func NewCustomCurrencyHandler added in v1.3.1

func NewCustomCurrencyHandler(service *currency.CustomService) *CustomCurrencyHandler

NewCustomCurrencyHandler creates the handler.

func (*CustomCurrencyHandler) Create added in v1.3.1

func (h *CustomCurrencyHandler) Create(c *gin.Context)

Create handles POST /custom-currency.

func (*CustomCurrencyHandler) Delete added in v1.3.1

func (h *CustomCurrencyHandler) Delete(c *gin.Context)

Delete handles DELETE /custom-currency/:id.

func (*CustomCurrencyHandler) DisableShare added in v1.3.1

func (h *CustomCurrencyHandler) DisableShare(c *gin.Context)

DisableShare handles DELETE /custom-currency/:id/share.

func (*CustomCurrencyHandler) EnableShare added in v1.3.1

func (h *CustomCurrencyHandler) EnableShare(c *gin.Context)

EnableShare handles POST /custom-currency/:id/share.

func (*CustomCurrencyHandler) Get added in v1.3.1

func (h *CustomCurrencyHandler) Get(c *gin.Context)

Get handles GET /custom-currency/:id.

func (*CustomCurrencyHandler) GetShared added in v1.3.1

func (h *CustomCurrencyHandler) GetShared(c *gin.Context)

GetShared handles GET /custom-currency/shared/:token — a read-only preview.

func (*CustomCurrencyHandler) Import added in v1.3.1

func (h *CustomCurrencyHandler) Import(c *gin.Context)

Import handles POST /custom-currency/shared/:token/import.

func (*CustomCurrencyHandler) List added in v1.3.1

func (h *CustomCurrencyHandler) List(c *gin.Context)

List handles GET /custom-currency.

func (*CustomCurrencyHandler) Preview added in v1.3.1

func (h *CustomCurrencyHandler) Preview(c *gin.Context)

Preview handles POST /custom-currency/preview.

func (*CustomCurrencyHandler) SetEnabled added in v1.3.1

func (h *CustomCurrencyHandler) SetEnabled(c *gin.Context)

SetEnabled handles PUT /custom-currency/:id/enabled — pause or resume a rule.

func (*CustomCurrencyHandler) SetNotify added in v1.3.1

func (h *CustomCurrencyHandler) SetNotify(c *gin.Context)

SetNotify handles PUT /custom-currency/:id/notify — opt a rule in/out of expiry notifications.

func (*CustomCurrencyHandler) Update added in v1.3.1

func (h *CustomCurrencyHandler) Update(c *gin.Context)

Update handles PUT /custom-currency/:id.

type MonthlyTrend

type MonthlyTrend struct {
	Month         string `json:"month"`
	TotalFlights  int    `json:"totalFlights"`
	TotalMinutes  int    `json:"totalMinutes"`
	PICMinutes    int    `json:"picMinutes"`
	DualMinutes   int    `json:"dualMinutes"`
	NightMinutes  int    `json:"nightMinutes"`
	IFRMinutes    int    `json:"ifrMinutes"`
	LandingsDay   int    `json:"landingsDay"`
	LandingsNight int    `json:"landingsNight"`
}

MonthlyTrend represents flight statistics for a single month

type TrendsResponse

type TrendsResponse struct {
	Monthly        []MonthlyTrend      `json:"monthly"`
	ByAircraftType []AircraftBreakdown `json:"byAircraftType"`
}

TrendsResponse contains all reporting data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL