Skip to content

Commit

Permalink
Add authToDiscardPushRequest localization
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmer committed Jan 6, 2025
1 parent 790dbe1 commit c217a80
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 38 deletions.
4 changes: 4 additions & 0 deletions lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Vyžadován zámek zařízení nebo biometrické ověření",
"authToAcceptPushRequest": "Pro přijetí požadavku na push notifikaci se přihlaste.",
"authToDeclinePushRequest": "Pro odmítnutí požadavku na push notifikaci se přihlaste.",
"authToDiscardPushRequest": "Ověřte, zda chcete požadavek na odeslání odmítnout.",
"authenticateToShowOtp": "Pro zobrazení jednorázového kódu se přihlaste.",
"authenticateToUnLockToken": "Pro změnu uzamčení tokenu se přihlaste.",
"authentication": "Žádost o ověření",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Gerätepasswort oder Biometrie wird benötigt",
"authToAcceptPushRequest": "Bitte authentifizieren Sie sich, um die Anfrage anzunehmen.",
"authToDeclinePushRequest": "Bitte authentifizieren Sie sich, um die Anfrage abzulehnen.",
"authToDiscardPushRequest": "Bitte authentifizieren Sie sich, um die Push-Anfrage zu verwerfen.",
"authenticateToShowOtp": "Bitte authentifizieren Sie sich, um das Einmalpasswort anzuzeigen.",
"authenticateToUnLockToken": "Bitte authentifizieren Sie sich, um den Sperrstatus des Tokens zu ändern.",
"authentication": "Authentifizierung",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Device credentials or biometrics required",
"authToAcceptPushRequest": "Please authenticate to accept the push request.",
"authToDeclinePushRequest": "Please authenticate to decline the push request.",
"authToDiscardPushRequest": "Please authenticate to reject the request.",
"authenticateToShowOtp": "Please authenticate to show one time password.",
"authenticateToUnLockToken": "Please authenticate to change the lock status of the token.",
"authentication": "Authentication",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Se requieren credenciales de dispositivo o datos biométricos",
"authToAcceptPushRequest": "Por favor, autentifíquese para aceptar la solicitud push.",
"authToDeclinePushRequest": "Por favor, autentifíquese para rechazar la solicitud push.",
"authToDiscardPushRequest": "Por favor, autentifíquese para descartar la solicitud push.",
"authenticateToShowOtp": "Por favor, autentifíquese para mostrar la contraseña de una sola vez.",
"authenticateToUnLockToken": "Por favor, autentifíquese para cambiar el estado de bloqueo del token.",
"authentication": "Autenticación",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Informations d'identification de l'appareil ou données biométriques requises",
"authToAcceptPushRequest": "Veuillez vous authentifier pour accepter la demande de connexion.",
"authToDeclinePushRequest": "Veuillez vous authentifier pour refuser la demande de connexion.",
"authToDiscardPushRequest": "Veuillez vous authentifier pour rejeter la demande de push.",
"authenticateToShowOtp": "Veuillez vous authentifier pour afficher un mot de passe à usage unique.",
"authenticateToUnLockToken": "Veuillez vous authentifier pour modifier l'état de verrouillage du jeton.",
"authentication": "Authentification",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_id.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Diperlukan kredensial atau biometrik perangkat",
"authToAcceptPushRequest": "Lakukan autentikasi untuk menerima permintaan push.",
"authToDeclinePushRequest": "Lakukan autentikasi untuk menolak permintaan push.",
"authToDiscardPushRequest": "Harap lakukan autentikasi untuk membuang permintaan push.",
"authenticateToShowOtp": "Harap lakukan autentikasi untuk menunjukkan kata sandi sekali pakai.",
"authenticateToUnLockToken": "Lakukan autentikasi untuk mengubah status kunci token.",
"authentication": "Otentikasi",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get authToDeclinePushRequest => 'Lakukan autentikasi untuk menolak permintaan push.';

@override
String get authToDiscardPushRequest => 'Harap lakukan autentikasi untuk membuang permintaan push.';

@override
String get authenticateToShowOtp => 'Harap lakukan autentikasi untuk menunjukkan kata sandi sekali pakai.';

Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,6 +1420,7 @@
"authNotSupportedTitle": "Apparaat inloggevens of biometrie is vereist",
"authToAcceptPushRequest": "Authenticeer om de push aanvraag te accepteren.",
"authToDeclinePushRequest": "Authenticeer om de push aanvraag te weigeren.",
"authToDiscardPushRequest": "Verifieer om het push verzoek te verwerpen.",
"authenticateToShowOtp": "Authenticeer om het eenmalige wachtwoord te tonen.",
"authenticateToUnLockToken": "Authenticeer om de vergrendeling van de token te wijzigen.",
"authentication": "Verificatieverzoek",
Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"@authToDeclinePushRequest": {
"description": "Message for declining a push request for authentication."
},
"@authToDiscardPushRequest": {
"description": "Message for discarding a push request for authentication."
},
"@authenticateToShowOtp": {
"description": "Reason to authenticate when trying to view a one time password."
},
Expand Down Expand Up @@ -1417,14 +1420,15 @@
"authNotSupportedTitle": "Skonfigurowane ustawienia zabezpieczeń albo uwierzytelnianie biometryczne jest wymagane.",
"authToAcceptPushRequest": "Uwierzytelnij, aby zaakceptować żądanie push.",
"authToDeclinePushRequest": "Uwierzytelnij, aby odrzucić żądanie push.",
"authToDiscardPushRequest": "Uwierzytelnij, aby wyrzucić żądanie.",
"authenticateToShowOtp": "Zweryfikuj tożsamość, by pokazać hasło jednorazowe.",
"authenticateToUnLockToken": "Zweryfikuj tożsamość, aby odblokować / zablokować token.",
"authentication": "Uwierzytelnianie",
"biometricHint": "Wymagana autentykacja",
"biometricNotRecognized": "Nie rozpoznano. Spróbuj ponownie.",
"biometricRequiredTitle": "Uwierzytelnianie biometryczne nie jest skonfigurowane.",
"biometricSuccess": "Autentykacja zakończona sukcesem!",
"butDiscardIt": "ale odrzucić go",
"butDiscardIt": "ale wyrzucić go",
"cancel": "Anuluj",
"checkServerCertificate": "Sprawdź certyfikat serwera",
"checkYourNetwork": "Sprawdź połączenie sieciowe i spróbuj ponownie.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../../utils/globals.dart';
import '../../../utils/lock_auth.dart';
import '../../../utils/riverpod/riverpod_providers/generated_providers/push_request_provider.dart';
import '../../../utils/riverpod/riverpod_providers/generated_providers/token_notifier.dart';
import '../../padded_row.dart';
import '../default_dialog.dart';
import 'push_request_dialog_widgets/push_accept_button.dart';
import 'push_request_dialog_widgets/push_decline_confirm_button.dart';
Expand Down Expand Up @@ -110,8 +111,8 @@ class _PushRequestDialogState extends ConsumerState<PushRequestDialog> {
peddingPercent: 0.33,
child: PushDeclineConfirmButton(
height: PushRequestDialog.buttonHeight,
onDecline: () => _onDecline(token),
onDiscard: () => _onDiscard(token),
onDecline: () => _onDecline(token),
confirmationTitle: title,
expirationDate: widget.pushRequest.expirationDate,
),
Expand All @@ -130,50 +131,19 @@ class _PushRequestDialogState extends ConsumerState<PushRequestDialog> {
if (mounted) setState(() => isHandled = true);
}

Future<void> _onDecline(PushToken token) async {
if (token.isLocked && !await lockAuth(reason: (localization) => localization.authToDeclinePushRequest, localization: AppLocalizations.of(context)!)) {
Future<void> _onDiscard(PushToken token) async {
if (token.isLocked && !await lockAuth(reason: (localization) => localization.authToDiscardPushRequest, localization: AppLocalizations.of(context)!)) {
return;
}
await ref.read(pushRequestProvider.notifier).decline(token, widget.pushRequest);
await ref.read(pushRequestProvider.notifier).remove(widget.pushRequest);
if (mounted) setState(() => isHandled = true);
}

Future<void> _onDiscard(PushToken token) async {
Future<void> _onDecline(PushToken token) async {
if (token.isLocked && !await lockAuth(reason: (localization) => localization.authToDeclinePushRequest, localization: AppLocalizations.of(context)!)) {
return;
}
await ref.read(pushRequestProvider.notifier).remove(widget.pushRequest);
await ref.read(pushRequestProvider.notifier).decline(token, widget.pushRequest);
if (mounted) setState(() => isHandled = true);
}
}

class PaddedRow extends StatelessWidget {
final double peddingPercent;
final Widget child;

/// Creates a row with padding on both sides of the child.
/// Example with 0.25 padding:
/// [ 0.125 | child | 0.125 ]
///
/// Assert that [peddingPercent] is higher than 0 and lower than 1.
const PaddedRow({super.key, required this.child, this.peddingPercent = 0.25}) : assert(peddingPercent > 0 && peddingPercent < 1);

@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
flex: (peddingPercent * 50).toInt(),
child: const SizedBox(),
),
Expanded(
flex: 100 - (peddingPercent * 100).toInt(),
child: child,
),
Expanded(
flex: (peddingPercent * 50).toInt(),
child: const SizedBox(),
),
],
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import '../../../../../../../widgets/dialog_widgets/push_request_dialog/push_req
import '../../../../l10n/app_localizations.dart';
import '../../../../utils/customization/theme_extentions/push_request_theme.dart';
import '../../../button_widgets/cooldown_button.dart';
import '../../../padded_row.dart';

class PushDeclineConfirmDialog extends StatefulWidget {
static Future<void> showDialogWidget({
Expand Down
51 changes: 51 additions & 0 deletions lib/widgets/padded_row.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* privacyIDEA Authenticator
*
* Author: Frank Merkel <frank.merkel@netknights.it>
*
* Copyright (c) 2025 NetKnights GmbH
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'package:flutter/material.dart';

class PaddedRow extends StatelessWidget {
final double peddingPercent;
final Widget child;

/// Creates a row with padding on both sides of the child.
/// Example with 0.25 padding:
/// [ 0.125 | child | 0.125 ]
///
/// Assert that [peddingPercent] is higher than 0 and lower than 1.
const PaddedRow({super.key, required this.child, this.peddingPercent = 0.25}) : assert(peddingPercent > 0 && peddingPercent < 1);

@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
flex: (peddingPercent * 50).toInt(),
child: const SizedBox(),
),
Expanded(
flex: 100 - (peddingPercent * 100).toInt(),
child: child,
),
Expanded(
flex: (peddingPercent * 50).toInt(),
child: const SizedBox(),
),
],
);
}

0 comments on commit c217a80

Please sign in to comment.