@inherits LoadedComponent @page "/impostazioni" @inject AnubisHost Host @inject ShellData Shell @inject SecondFactorDrafts Drafts Impostazioni · Anubis @* First part of SPEC 13.5: appearance, security, system. The other sections arrive with their phases. *@ @if (Ok is { } ok) {

@(ok switch { "password" => "Password cambiata. Le altre sessioni sono state chiuse.", "due-fattori" => "Secondo fattore attivato.", "due-fattori-tolti" => "Secondo fattore disattivato.", "salvataggio" => "Salvataggio fatto.", _ => "Fatto.", })

} @if (ErrorText is { } error) { }

Aspetto

@foreach (var setting in _appearance) { var definition = SettingsStore.Definition(setting.Key);
@if (setting.ReadOnly) { Fissato da @setting.Source: si cambia lì. } else { } }

Gli importi in dollari usano il cambio del giorno, che arriva con i dati di mercato. Fino ad allora restano in euro.

Sicurezza

@if (Shell.IsDemo) {

Nella modalità dimostrativa password e secondo fattore non si cambiano.

} else {

Password

Secondo fattore

@if (_hasSecondFactor) {

Attivo: all'accesso chiedo anche il codice dell'app. Servirà anche per attivare i soldi veri.

} else {

Facoltativo: un codice di sei cifre da un'app di autenticazione (per esempio quella del tuo gestore di password), oltre alla password.

  1. Nell'app scegli "aggiungi con chiave" e scrivi questa chiave: @_draft
  2. Oppure, se l'app accetta un indirizzo, usa: @_draftUri
  3. Scrivi qui il codice che l'app mostra.
}
}

Sistema

Piattaforma
@(Host.Config.Platform == PlatformKind.Docker ? "Docker" : "Desktop (Windows)")
Database
@Host.Config.Db?.Describe()
Cartella dei dati
@Host.Config.Data.Root
Chiave dei segreti
@Host.Config.SecretKey.Description
Fuso orario
@Host.Config.TimeZone.Id
Versione
@AnubisInfo.Version

@if (Host.Config.Platform == PlatformKind.Docker) { @:Motore e connessione del database si cambiano solo nella configurazione del container. } else { @:Motore e connessione del database stanno in config.toml, nella cartella dei dati. Lo spostamento su un altro database arriva con l'applicazione desktop. }

Salvataggi

Ogni notte alle 03:30 e prima di ogni aggiornamento dello schema. Tengo gli ultimi @Backups.Keep.

@if (_backups.Count > 0) {
@foreach (var b in _backups) { }
QuandoPerchéCartella
@Format.ShortDate(b.TakenAt, Shell.Now, Shell.Zone)@b.Reason@b.Name
}

Registro delle modifiche

@if (_history.Count == 0) {

Nessuna modifica finora.

} else {
@foreach (var h in _history) { }
QuandoVocePrimaDopoChi
@Format.ShortDate(h.At, Shell.Now, Shell.Zone)@h.Key@Label(h.OldValue)@Label(h.NewValue)@h.ChangedBy
}
@code { private readonly List _appearance = []; private List _history = []; private IReadOnlyList _backups = []; private bool _hasSecondFactor; private string? _draft; private string? _draftUri; [CascadingParameter] public HttpContext? HttpContext { get; set; } [SupplyParameterFromQuery(Name = "ok")] public string? Ok { get; set; } [SupplyParameterFromQuery(Name = "errore")] public string? Errore { get; set; } protected override async Task LoadAsync() { var ct = HttpContext?.RequestAborted ?? CancellationToken.None; var services = Host.Services!; _appearance.Add(await services.Settings.GetAsync(SettingsStore.Theme.Key, ct)); _appearance.Add(await services.Settings.GetAsync(SettingsStore.Currency.Key, ct)); _history = await services.Settings.HistoryAsync(null, 50, ct); _backups = services.Backups.List(); var user = HttpContext!.User; _hasSecondFactor = CurrentUser.HasSecondFactor(user); if (!_hasSecondFactor && !Shell.IsDemo) { var secret = Drafts.For(CurrentUser.Session(user)); _draft = Base32.Encode(secret); _draftUri = Totp.Uri("Anubis", AccessStore.AdminName, secret); } } private string? ErrorText => Errore switch { "codice" => "Il codice non è giusto. Controlla l'ora del telefono e riprova con il codice che vedi adesso.", "segreto" => "La chiave è scaduta: ricarica la pagina e aggiungi di nuovo Anubis nell'app.", "salvataggio" => "Il salvataggio non è riuscito. Controlla lo spazio libero nella cartella dei dati.", "impostazione" => "Questa impostazione non si può cambiare così.", "bot" => "Comando non ammesso nello stato attuale del bot.", _ => PasswordMessages.For(Errore), }; private static string Label(string? value) => value switch { null => "—", "auto" => "Come il sistema", "light" => "Chiaro", "dark" => "Scuro", "EUR" => "Euro (EUR)", "USD" => "Dollaro (USD)", "active" => "Attivo", "paused" => "In pausa", "stopped" => "Fermo", _ => value.Trim('"'), }; }